lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.121.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.123.0

- old
+ new

@@ -151,10 +151,14 @@ def refund(money, identification, options = {}) commit(build_refund_request(money, identification, options), :refund, money, options) end + def adjust(money, authorization, options = {}) + commit(build_adjust_request(money, authorization, options), :adjust, money, options) + end + def verify(payment, options = {}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, payment, options) } r.process(:ignore_result) { void(r.authorization, options) } end @@ -283,10 +287,11 @@ end end def build_auth_request(money, creditcard_or_reference, options) xml = Builder::XmlMarkup.new indent: 2 + add_customer_id(xml, options) add_payment_method_or_subscription(xml, money, creditcard_or_reference, options) add_threeds_2_ucaf_data(xml, creditcard_or_reference, options) add_decision_manager_fields(xml, options) add_mdd_fields(xml, options) add_auth_service(xml, creditcard_or_reference, options) @@ -298,11 +303,19 @@ add_partner_solution_id(xml) add_stored_credential_options(xml, options) add_merchant_description(xml, options) add_sales_slip_number(xml, options) add_airline_data(xml, options) + xml.target! + end + def build_adjust_request(money, authorization, options) + _, request_id = authorization.split(';') + + xml = Builder::XmlMarkup.new indent: 2 + add_purchase_data(xml, money, true, options) + add_incremental_auth_service(xml, request_id, options) xml.target! end def build_tax_calculation_request(creditcard, options) xml = Builder::XmlMarkup.new indent: 2 @@ -332,10 +345,11 @@ xml.target! end def build_purchase_request(money, payment_method_or_reference, options) xml = Builder::XmlMarkup.new indent: 2 + add_customer_id(xml, options) add_payment_method_or_subscription(xml, money, payment_method_or_reference, options) add_threeds_2_ucaf_data(xml, payment_method_or_reference, options) add_decision_manager_fields(xml, options) add_mdd_fields(xml, options) add_sales_slip_number(xml, options) @@ -470,12 +484,12 @@ def add_business_rules_data(xml, payment_method, options) prioritized_options = [options, @options] unless network_tokenization?(payment_method) xml.tag! 'businessRules' do - xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs) - xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv) + xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs).to_s == 'true' + xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv).to_s == 'true' end end end def extract_option(prioritized_options, option_name) @@ -513,10 +527,16 @@ xml.tag! 'invoiceHeader' do xml.tag! 'merchantDescriptor', options[:merchant_descriptor] end end + def add_customer_id(xml, options) + return unless options[:customer_id] + + xml.tag! 'customerID', options[:customer_id] + end + def add_merchant_description(xml, options) return unless options[:merchant_descriptor_name] || options[:merchant_descriptor_address1] || options[:merchant_descriptor_locality] xml.tag! 'merchantInformation' do xml.tag! 'merchantDescriptor' do @@ -583,11 +603,11 @@ def add_creditcard(xml, creditcard) xml.tag! 'card' do xml.tag! 'accountNumber', creditcard.number xml.tag! 'expirationMonth', format(creditcard.month, :two_digits) xml.tag! 'expirationYear', format(creditcard.year, :four_digits) - xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank? + xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv].to_s == 'true' || creditcard.verification_value.blank? xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym] end end def add_decision_manager_fields(xml, options) @@ -654,9 +674,16 @@ xml.tag!('commerceIndicator', indicator) if indicator end xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end end + end + + def add_incremental_auth_service(xml, authorization, options) + xml.tag! 'ccIncrementalAuthService', { 'run' => 'true' } do + xml.tag! 'authRequestID', authorization + end + xml.tag! 'subsequentAuthReason', options[:auth_reason] end def add_normalized_threeds_2_data(xml, payment_method, options) threeds_2_options = options[:three_d_secure] cc_brand = card_brand(payment_method).to_sym