lib/active_merchant/billing/integrations/helper.rb in yetanothernguyen-activemerchant-1.16.0 vs lib/active_merchant/billing/integrations/helper.rb in yetanothernguyen-activemerchant-1.21.0
- old
+ new
@@ -12,12 +12,14 @@
# Useful for things like the PayPal build notation (BN) id fields
class_attribute :application_id
self.application_id = 'ActiveMerchant'
def initialize(order, account, options = {})
- options.assert_valid_keys([:amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name])
- @fields = {}
+ options.assert_valid_keys([:amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name, :transaction_type])
+ @fields = {}
+ @raw_html_fields = []
+ @test = options[:test]
self.order = order
self.account = account
self.amount = options[:amount]
self.currency = options[:currency]
self.credential2 = options[:credential2]
@@ -40,19 +42,34 @@
field = mappings[subkey][k]
add_field(field, v) unless field.blank?
end
end
+ # Add a field that has characters that CGI::escape would mangle. Allows
+ # for multiple fields with the same name (e.g., to support line items).
+ def add_raw_html_field(name, value)
+ return if name.blank? || value.blank?
+ @raw_html_fields << [name, value]
+ end
+
+ def raw_html_fields
+ @raw_html_fields
+ end
+
def billing_address(params = {})
add_address(:billing_address, params)
end
def shipping_address(params = {})
add_address(:shipping_address, params)
end
def form_fields
@fields
+ end
+
+ def test?
+ @test_mode ||= ActiveMerchant::Billing::Base.integration_mode == :test || @test
end
private
def add_address(key, params)