lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.103.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.104.0

- old
+ new

@@ -286,10 +286,11 @@ order_id, request_id, request_token = authorization.split(';') options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 add_purchase_data(xml, money, true, options) + add_other_tax(xml, options) add_mdd_fields(xml, options) add_capture_service(xml, request_id, request_token) add_business_rules_data(xml, authorization, options) add_issuer_additional_data(xml, options) xml.target! @@ -318,15 +319,18 @@ order_id, request_id, request_token, action, money, currency = identification.split(';') options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 if action == 'capture' + add_mdd_fields(xml, options) add_void_service(xml, request_id, request_token) else add_purchase_data(xml, money, true, options.merge(:currency => currency || default_currency)) + add_mdd_fields(xml, options) add_auth_reversal_service(xml, request_id, request_token) end + add_issuer_additional_data(xml, options) xml.target! end def build_refund_request(money, identification, options) order_id, request_id, request_token = identification.split(';') @@ -341,11 +345,13 @@ def build_credit_request(money, creditcard_or_reference, options) xml = Builder::XmlMarkup.new :indent => 2 add_payment_method_or_subscription(xml, money, creditcard_or_reference, options) + add_mdd_fields(xml, options) add_credit_service(xml) + add_issuer_additional_data(xml, options) xml.target! end def build_create_subscription_request(payment_method, options) @@ -445,12 +451,21 @@ xml.tag! 'merchantID', @options[:login] xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id xml.tag! 'clientLibrary', 'Ruby Active Merchant' xml.tag! 'clientLibraryVersion', VERSION xml.tag! 'clientEnvironment', RUBY_PLATFORM + add_merchant_descriptor(xml, options) end + def add_merchant_descriptor(xml, options) + return unless options[:merchant_descriptor] + + xml.tag! 'invoiceHeader' do + xml.tag! 'merchantDescriptor', options[:merchant_descriptor] + end + end + def add_purchase_data(xml, money = 0, include_grand_total = false, options={}) xml.tag! 'purchaseTotals' do xml.tag! 'currency', options[:currency] || currency(money) xml.tag!('grandTotalAmount', localized_amount(money.to_i, options[:currency] || default_currency)) if include_grand_total end @@ -501,10 +516,19 @@ xml.tag! 'issuer' do xml.tag! 'additionalData', options[:issuer_additional_data] end end + def add_other_tax(xml, options) + return unless options[:local_tax_amount] || options[:national_tax_amount] + + xml.tag! 'otherTax' do + xml.tag! 'localTaxAmount', options[:local_tax_amount] if options[:local_tax_amount] + xml.tag! 'nationalTaxAmount', options[:national_tax_amount] if options[:national_tax_amount] + 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| @@ -568,10 +592,11 @@ end def stored_credential_commerce_indicator(options) return unless options[:stored_credential] return if options[:stored_credential][:initial_transaction] + case options[:stored_credential][:reason_type] when 'installment' then 'install' when 'recurring' then 'recurring' end end @@ -706,23 +731,34 @@ end def add_payment_method_or_subscription(xml, money, payment_method_or_reference, options) if payment_method_or_reference.is_a?(String) add_purchase_data(xml, money, true, options) + add_installments(xml, options) add_subscription(xml, options, payment_method_or_reference) elsif card_brand(payment_method_or_reference) == 'check' add_address(xml, payment_method_or_reference, options[:billing_address], options) add_purchase_data(xml, money, true, options) + add_installments(xml, options) add_check(xml, payment_method_or_reference) else add_address(xml, payment_method_or_reference, options[:billing_address], options) add_address(xml, payment_method_or_reference, options[:shipping_address], options, true) add_purchase_data(xml, money, true, options) + add_installments(xml, options) add_creditcard(xml, payment_method_or_reference) end end + def add_installments(xml, options) + return unless options[:installment_total_count] + + xml.tag! 'installment' do + xml.tag! 'totalCount', options[:installment_total_count] + end + end + def add_validate_pinless_debit_service(xml) xml.tag! 'pinlessDebitValidateService', {'run' => 'true'} end def add_threeds_services(xml, options) @@ -739,10 +775,11 @@ 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] @@ -840,9 +877,10 @@ return reply end def reason_message(reason_code) return if reason_code.blank? + @@response_codes[:"r#{reason_code}"] end def authorization_from(response, action, amount, options) [options[:order_id], response[:requestID], response[:requestToken], action, amount,