lib/active_merchant/billing/gateways/braintree_blue.rb in yetanothernguyen-activemerchant-1.16.0 vs lib/active_merchant/billing/gateways/braintree_blue.rb in yetanothernguyen-activemerchant-1.21.0
- old
+ new
@@ -16,14 +16,15 @@
self.display_name = 'Braintree (Blue Platform)'
def initialize(options = {})
requires!(options, :merchant_id, :public_key, :private_key)
@options = options
+ @merchant_account_id = options[:merchant_account_id]
Braintree::Configuration.merchant_id = options[:merchant_id]
Braintree::Configuration.public_key = options[:public_key]
Braintree::Configuration.private_key = options[:private_key]
- Braintree::Configuration.environment = test? ? :sandbox : :production
+ Braintree::Configuration.environment = (options[:environment] || (test? ? :sandbox : :production)).to_sym
Braintree::Configuration.logger.level = Logger::ERROR if Braintree::Configuration.logger
Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
super
end
@@ -173,11 +174,15 @@
:code => nil, :message => nil,
:street_match => result.transaction.avs_street_address_response_code,
:postal_match => result.transaction.avs_postal_code_response_code
}
response_options[:cvv_result] = result.transaction.cvv_response_code
- message = "#{result.transaction.processor_response_code} #{result.transaction.processor_response_text}"
+ if result.transaction.status == "gateway_rejected"
+ message = "Transaction declined - gateway rejected"
+ else
+ message = "#{result.transaction.processor_response_code} #{result.transaction.processor_response_text}"
+ end
else
message = message_from_result(result)
end
response = Response.new(result.success?, message, response_params, response_options)
response.cvv_result['message'] = ''
@@ -274,11 +279,11 @@
:options => {
:store_in_vault => options[:store] ? true : false,
:submit_for_settlement => options[:submit_for_settlement]
}
}
- if options.has_key?(:merchant_account_id)
- parameters[:merchant_account_id] = options[:merchant_account_id]
+ if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
+ parameters[:merchant_account_id] = merchant_account_id
end
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
parameters[:customer_id] = credit_card_or_vault_id
else
parameters[:customer].merge!(