lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.91.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.92.0
- old
+ new
@@ -22,11 +22,11 @@
# the documentation exactly.
class CyberSourceGateway < Gateway
self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
- XSD_VERSION = '1.121'
+ XSD_VERSION = '1.153'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
self.default_currency = 'USD'
@@ -258,10 +258,11 @@
add_mdd_fields(xml, options)
add_auth_service(xml, creditcard_or_reference, options)
add_threeds_services(xml, options)
add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
add_business_rules_data(xml, creditcard_or_reference, options)
+ add_stored_credential_options(xml, options)
xml.target!
end
def build_tax_calculation_request(creditcard, options)
xml = Builder::XmlMarkup.new :indent => 2
@@ -511,14 +512,31 @@
def add_auth_service(xml, payment_method, options)
if network_tokenization?(payment_method)
add_auth_network_tokenization(xml, payment_method, options)
else
- xml.tag! 'ccAuthService', {'run' => 'true'}
+ xml.tag! 'ccAuthService', {'run' => 'true'} do
+ check_for_stored_cred_commerce_indicator(xml, options)
+ end
end
end
+ def check_for_stored_cred_commerce_indicator(xml, options)
+ return unless options[:stored_credential]
+ if commerce_indicator(options)
+ xml.tag!('commerceIndicator', commerce_indicator(options))
+ end
+ end
+
+ def commerce_indicator(options)
+ return if options[:stored_credential][:initial_transaction]
+ case options[:stored_credential][:reason_type]
+ when 'installment' then 'install'
+ when 'recurring' then 'recurring'
+ end
+ end
+
def network_tokenization?(payment_method)
payment_method.is_a?(NetworkTokenizationCreditCard)
end
def add_auth_network_tokenization(xml, payment_method, options)
@@ -676,9 +694,21 @@
end
def lookup_country_code(country_field)
country_code = Country.find(country_field) rescue nil
country_code&.code(:alpha2)
+ end
+
+ def add_stored_credential_options(xml, options={})
+ return unless options[:stored_credential]
+ if options[:stored_credential][:initial_transaction]
+ xml.tag! 'subsequentAuthFirst', 'true'
+ elsif options[:stored_credential][:reason_type] == 'unscheduled'
+ xml.tag! 'subsequentAuth', 'true'
+ xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
+ else
+ xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
+ end
end
# Where we actually build the full SOAP request using builder
def build_request(body, options)
xml = Builder::XmlMarkup.new :indent => 2