diff --git a/core/app/models/spree/payment_method/bogus_credit_card.rb b/core/app/models/spree/payment_method/bogus_credit_card.rb index a5983b04c9d..85e24734ce6 100644 --- a/core/app/models/spree/payment_method/bogus_credit_card.rb +++ b/core/app/models/spree/payment_method/bogus_credit_card.rb @@ -29,39 +29,44 @@ def create_profile(payment) def authorize(_money, credit_card, _options = {}) profile_id = credit_card.gateway_customer_profile_id + message_detail = " - #{__method__}" if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-')) - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'D' }) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'D' }) else - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, test: true) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, { message: FAILURE_MESSAGE + message_detail }, test: true) end end def purchase(_money, credit_card, _options = {}) profile_id = credit_card.gateway_customer_profile_id + message_detail = " - #{__method__}" if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-')) - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'M' }) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'M' }) else - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, message: FAILURE_MESSAGE + message_detail, test: true) end end def credit(_money, _credit_card, _response_code, _options = {}) - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE) + message_detail = " - #{__method__}" + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE) end def capture(_money, authorization, _gateway_options) + message_detail = " - #{__method__}" if authorization == '12345' - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true) else - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, error: FAILURE_MESSAGE, test: true) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, error: FAILURE_MESSAGE + message_detail, test: true) end end def void(_response_code, _credit_card, options = {}) + message_detail = " - #{__method__}" if options[:originator].completed? - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE) else - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE) end end diff --git a/core/app/models/spree/payment_method/simple_bogus_credit_card.rb b/core/app/models/spree/payment_method/simple_bogus_credit_card.rb index 5065300b033..46372c69047 100644 --- a/core/app/models/spree/payment_method/simple_bogus_credit_card.rb +++ b/core/app/models/spree/payment_method/simple_bogus_credit_card.rb @@ -8,26 +8,32 @@ def payment_profiles_supported? end def authorize(_money, credit_card, _options = {}) + message_detail = " - #{__method__}" + if VALID_CCS.include? credit_card.number - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' }) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' }) else - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, test: true) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, { message: FAILURE_MESSAGE }, test: true) end end def purchase(_money, credit_card, _options = {}) + message_detail = " - #{__method__}" + if VALID_CCS.include? credit_card.number - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' }) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' }) else - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, message: FAILURE_MESSAGE, test: true) end end def void(_response_code, options = {}) + message_detail = " - #{__method__}" + if options[:originator].completed? - ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE) + ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE) else - ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE) + ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE) end end end diff --git a/core/spec/models/spree/refund_spec.rb b/core/spec/models/spree/refund_spec.rb index 1cf6ac4acff..10ff8c13917 100644 --- a/core/spec/models/spree/refund_spec.rb +++ b/core/spec/models/spree/refund_spec.rb @@ -63,7 +63,7 @@ expect { subject }.to change { refund.perform_response }.from(nil) expect(refund.perform_response).to be_a(ActiveMerchant::Billing::Response) - expect(refund.perform_response.message).to eq(Spree::PaymentMethod::BogusCreditCard::SUCCESS_MESSAGE) + expect(refund.perform_response.message).to include(Spree::PaymentMethod::BogusCreditCard::SUCCESS_MESSAGE) end it "sets a transaction_id" do