lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.68.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.69.0
- old
+ new
@@ -256,10 +256,11 @@
xml = Builder::XmlMarkup.new :indent => 2
add_payment_method_or_subscription(xml, 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
def build_tax_calculation_request(creditcard, options)
@@ -291,10 +292,11 @@
add_mdd_fields(xml, options)
if !payment_method_or_reference.is_a?(String) && card_brand(payment_method_or_reference) == 'check'
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!
end
@@ -353,10 +355,11 @@
if options[:setup_fee]
if card_brand(payment_method) == 'check'
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)
add_business_rules_data(xml, payment_method, options)
xml.target!
@@ -469,17 +472,21 @@
xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym]
end
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]
end
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
xml.tag!("field#{each}", options[key]) if options[key]
end
@@ -501,21 +508,21 @@
end
end
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
end
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
when :visa
xml.tag! 'ccAuthService', {'run' => 'true'} do
@@ -537,12 +544,14 @@
xml.tag!("cavv", Base64.encode64(cryptogram[0...20]))
xml.tag!("commerceIndicator", "aesk")
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
def add_capture_service(xml, request_id, request_token)
xml.tag! 'ccCaptureService', {'run' => 'true'} do