lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.114.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.116.0

- old
+ new

@@ -388,11 +388,11 @@ xml.target! end def build_create_subscription_request(payment_method, options) - default_subscription_params = {frequency: 'on-demand', amount: 0, automatic_renew: false} + default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false } options[:subscription] = default_subscription_params.update( options[:subscription] || {} ) xml = Builder::XmlMarkup.new indent: 2 @@ -470,11 +470,11 @@ options_matching_key[option_name] if options_matching_key end def add_line_item_data(xml, options) options[:line_items].each_with_index do |value, index| - xml.tag! 'item', {'id' => index} do + xml.tag! 'item', { 'id' => index } do xml.tag! 'unitPrice', localized_amount(value[:declared_value].to_i, options[:currency] || default_currency) xml.tag! 'quantity', value[:quantity] xml.tag! 'productCode', value[:code] || 'shipping_only' xml.tag! 'productName', value[:description] xml.tag! 'productSKU', value[:sku] @@ -510,11 +510,11 @@ xml.tag! 'locality', options[:merchant_descriptor_locality] if options[:merchant_descriptor_locality] end end end - def add_purchase_data(xml, money = 0, include_grand_total = false, options={}) + 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 end @@ -574,11 +574,11 @@ 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') } + return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') && options[key] } xml.tag! 'merchantDefinedData' do (1..100).each do |each| key = "mdd_field_#{each}".to_sym xml.tag!("field#{each}", options[key]) if options[key] @@ -593,21 +593,21 @@ xml.tag! 'bankTransitNumber', check.routing_number end end def add_tax_service(xml) - xml.tag! 'taxService', {'run' => 'true'} do + xml.tag! 'taxService', { 'run' => 'true' } do xml.tag!('nexus', @options[:nexus]) unless @options[:nexus].blank? xml.tag!('sellerRegistration', @options[:vat_reg_number]) unless @options[:vat_reg_number].blank? end end 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'} do + xml.tag! 'ccAuthService', { 'run' => 'true' } do if options[:three_d_secure] add_normalized_threeds_2_data(xml, payment_method, options) else indicator = options[:commerce_indicator] || stored_credential_commerce_indicator(options) xml.tag!('commerceIndicator', indicator) if indicator @@ -676,28 +676,28 @@ brand = card_brand(payment_method).to_sym case brand when :visa - xml.tag! 'ccAuthService', {'run' => 'true'} do + xml.tag! 'ccAuthService', { 'run' => 'true' } do xml.tag!('cavv', payment_method.payment_cryptogram) xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand]) xml.tag!('xid', payment_method.payment_cryptogram) xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end when :master xml.tag! 'ucaf' do xml.tag!('authenticationData', payment_method.payment_cryptogram) xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR) end - xml.tag! 'ccAuthService', {'run' => 'true'} do + xml.tag! 'ccAuthService', { 'run' => 'true' } do xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand]) xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end when :american_express cryptogram = Base64.decode64(payment_method.payment_cryptogram) - xml.tag! 'ccAuthService', {'run' => 'true'} do + xml.tag! 'ccAuthService', { 'run' => 'true' } do xml.tag!('cavv', Base64.encode64(cryptogram[0...20])) xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand]) xml.tag!('xid', Base64.encode64(cryptogram[20...40])) xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end @@ -709,69 +709,69 @@ xml.tag!('transactionType', '1') end end def add_capture_service(xml, request_id, request_token) - xml.tag! 'ccCaptureService', {'run' => 'true'} do + xml.tag! 'ccCaptureService', { 'run' => 'true' } do xml.tag! 'authRequestID', request_id xml.tag! 'authRequestToken', request_token xml.tag! 'reconciliationID', options[:reconciliation_id] if options[:reconciliation_id] end end def add_purchase_service(xml, payment_method, options) if options[:pinless_debit_card] - xml.tag! 'pinlessDebitService', {'run' => 'true'} do + xml.tag! 'pinlessDebitService', { 'run' => 'true' } do xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end else add_auth_service(xml, payment_method, options) - xml.tag! 'ccCaptureService', {'run' => 'true'} do + xml.tag! 'ccCaptureService', { 'run' => 'true' } do xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id] end end end def add_void_service(xml, request_id, request_token) - xml.tag! 'voidService', {'run' => 'true'} do + xml.tag! 'voidService', { 'run' => 'true' } do xml.tag! 'voidRequestID', request_id xml.tag! 'voidRequestToken', request_token end end def add_auth_reversal_service(xml, request_id, request_token) - xml.tag! 'ccAuthReversalService', {'run' => 'true'} do + xml.tag! 'ccAuthReversalService', { 'run' => 'true' } do xml.tag! 'authRequestID', request_id xml.tag! 'authRequestToken', request_token end end def add_credit_service(xml, request_id = nil, request_token = nil) - xml.tag! 'ccCreditService', {'run' => 'true'} do + xml.tag! 'ccCreditService', { 'run' => 'true' } do xml.tag! 'captureRequestID', request_id if request_id xml.tag! 'captureRequestToken', request_token if request_token end end def add_check_service(xml) - xml.tag! 'ecDebitService', {'run' => 'true'} + xml.tag! 'ecDebitService', { 'run' => 'true' } end def add_subscription_create_service(xml, options) - xml.tag! 'paySubscriptionCreateService', {'run' => 'true'} + xml.tag! 'paySubscriptionCreateService', { 'run' => 'true' } end def add_subscription_update_service(xml, options) - xml.tag! 'paySubscriptionUpdateService', {'run' => 'true'} + xml.tag! 'paySubscriptionUpdateService', { 'run' => 'true' } end def add_subscription_delete_service(xml, options) - xml.tag! 'paySubscriptionDeleteService', {'run' => 'true'} + xml.tag! 'paySubscriptionDeleteService', { 'run' => 'true' } end def add_subscription_retrieve_service(xml, options) - xml.tag! 'paySubscriptionRetrieveService', {'run' => 'true'} + xml.tag! 'paySubscriptionRetrieveService', { 'run' => 'true' } end def add_subscription(xml, options, reference = nil) options[:subscription] ||= {} @@ -832,38 +832,38 @@ xml.tag! 'totalCount', options[:installment_total_count] end end def add_validate_pinless_debit_service(xml) - xml.tag! 'pinlessDebitValidateService', {'run' => 'true'} + xml.tag! 'pinlessDebitValidateService', { 'run' => 'true' } end def add_threeds_services(xml, options) - xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] + xml.tag! 'payerAuthEnrollService', { 'run' => 'true' } if options[:payer_auth_enroll_service] if options[:payer_auth_validate_service] - xml.tag! 'payerAuthValidateService', {'run' => 'true'} do + xml.tag! 'payerAuthValidateService', { 'run' => 'true' } do xml.tag! 'signedPARes', options[:pares] end end end def lookup_country_code(country_field) country_code = Country.find(country_field) rescue nil country_code&.code(:alpha2) end - def add_stored_credential_subsequent_auth(xml, options={}) + def add_stored_credential_subsequent_auth(xml, options = {}) return unless options[:stored_credential] || options[:stored_credential_overrides] stored_credential_subsequent_auth = 'true' if options.dig(:stored_credential, :initiator) == 'merchant' override_subsequent_auth = options.dig(:stored_credential_overrides, :subsequent_auth) xml.subsequentAuth override_subsequent_auth.nil? ? stored_credential_subsequent_auth : override_subsequent_auth end - def add_stored_credential_options(xml, options={}) + def add_stored_credential_options(xml, options = {}) return unless options[:stored_credential] || options[:stored_credential_overrides] stored_credential_subsequent_auth_first = 'true' if options.dig(:stored_credential, :initial_transaction) stored_credential_transaction_id = options.dig(:stored_credential, :network_transaction_id) if options.dig(:stored_credential, :initiator) == 'merchant' stored_credential_subsequent_auth_stored_cred = 'true' if options.dig(:stored_credential, :initiator) == 'cardholder' && !options.dig(:stored_credential, :initial_transaction) || options.dig(:stored_credential, :initiator) == 'merchant' && options.dig(:stored_credential, :reason_type) == 'unscheduled' @@ -887,21 +887,21 @@ def build_request(body, options) xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION xml = Builder::XmlMarkup.new indent: 2 xml.instruct! - xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do + xml.tag! 's:Envelope', { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/' } do xml.tag! 's:Header' do - xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do + xml.tag! 'wsse:Security', { 's:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' } do xml.tag! 'wsse:UsernameToken' do xml.tag! 'wsse:Username', @options[:login] xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText' end end end - xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do - xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}"} do + xml.tag! 's:Body', { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do + xml.tag! 'requestMessage', { 'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}" } do add_merchant_data(xml, options) xml << body end end end @@ -930,11 +930,10 @@ Response.new(success, message, response, test: test?, authorization: authorization, fraud_review: in_fraud_review?(response), avs_result: { code: response[:avsCode] }, - cvv_result: response[:cvCode] - ) + cvv_result: response[:cvCode]) end # Parse the SOAP response # Technique inspired by the Paypal Gateway def parse(xml)