lib/active_merchant/billing/gateways/element.rb in activemerchant-1.126.0 vs lib/active_merchant/billing/gateways/element.rb in activemerchant-1.129.0
- old
+ new
@@ -15,10 +15,15 @@
self.display_name = 'Element'
SERVICE_TEST_URL = 'https://certservices.elementexpress.com/express.asmx'
SERVICE_LIVE_URL = 'https://services.elementexpress.com/express.asmx'
+ NETWORK_TOKEN_TYPE = {
+ apple_pay: '2',
+ google_pay: '1'
+ }
+
def initialize(options = {})
requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version)
super
end
@@ -169,10 +174,12 @@
def add_payment_method(xml, payment)
if payment.is_a?(String)
add_payment_account_id(xml, payment)
elsif payment.is_a?(Check)
add_echeck(xml, payment)
+ elsif payment.is_a?(NetworkTokenizationCreditCard)
+ add_network_tokenization_card(xml, payment)
else
add_credit_card(xml, payment)
end
end
@@ -198,11 +205,11 @@
xml.transaction do
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 market_code(money, options) if options[:market_code] || money
- xml.ReferenceNumber options[:order_id] || SecureRandom.hex(20)
+ xml.ReferenceNumber options[:order_id].present? ? options[:order_id][0, 50] : SecureRandom.hex(20)
xml.TicketNumber options[:ticket_number] if options[:ticket_number]
xml.MerchantSuppliedTransactionId options[:merchant_supplied_transaction_id] if options[:merchant_supplied_transaction_id]
xml.PaymentType options[:payment_type] if options[:payment_type]
xml.SubmissionType options[:submission_type] if options[:submission_type]
xml.DuplicateCheckDisableFlag options[:duplicate_check_disable_flag].to_s == 'true' ? 'True' : 'False' unless options[:duplicate_check_disable_flag].nil?
@@ -244,11 +251,24 @@
xml.RoutingNumber payment.routing_number
xml.DDAAccountType payment.account_type.capitalize
end
end
+ def add_network_tokenization_card(xml, payment)
+ xml.card do
+ 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.Cryptogram payment.payment_cryptogram
+ xml.ElectronicCommerceIndicator payment.eci if payment.eci.present?
+ xml.WalletType NETWORK_TOKEN_TYPE.fetch(payment.source, '0')
+ end
+ end
+
def add_address(xml, options)
if address = options[:billing_address] || options[:address]
+ address[:email] ||= options[:email]
xml.address do
xml.BillingAddress1 address[:address1] if address[:address1]
xml.BillingAddress2 address[:address2] if address[:address2]
xml.BillingCity address[:city] if address[:city]
xml.BillingState address[:state] if address[:state]