lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.125.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.126.0
- old
+ new
@@ -13,13 +13,10 @@
# registration number in the options hash as vat_reg_number.
# * productCode is a value in the line_items hash that is used to tell
# CyberSource what kind of item you are selling. It is used when
# calculating tax/VAT.
# * All transactions use dollar values.
- # * To process pinless debit cards through the pinless debit card
- # network, your Cybersource merchant account must accept pinless
- # debit card payments.
# * The order of the XML elements does matter, make sure to follow the order in
# 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'
@@ -137,11 +134,10 @@
def capture(money, authorization, options = {})
setup_address_hash(options)
commit(build_capture_request(money, authorization, options), :capture, money, options)
end
- # options[:pinless_debit_card] => true # attempts to process as pinless debit card
def purchase(money, payment_method_or_reference, options = {})
setup_address_hash(options)
commit(build_purchase_request(money, payment_method_or_reference, options), :purchase, money, options)
end
@@ -156,13 +152,14 @@
def adjust(money, authorization, options = {})
commit(build_adjust_request(money, authorization, options), :adjust, money, options)
end
def verify(payment, options = {})
+ amount = eligible_for_zero_auth?(payment, options) ? 0 : 100
MultiResponse.run(:use_first_response) do |r|
- r.process { authorize(100, payment, options) }
- r.process(:ignore_result) { void(r.authorization, options) }
+ r.process { authorize(amount, payment, options) }
+ r.process(:ignore_result) { void(r.authorization, options) } unless amount == 0
end
end
# Adds credit to a card or subscription (stand alone credit).
def credit(money, creditcard_or_reference, options = {})
@@ -227,16 +224,10 @@
requires!(options, :line_items)
setup_address_hash(options)
commit(build_tax_calculation_request(creditcard, options), :calculate_tax, nil, options)
end
- # Determines if a card can be used for Pinless Debit Card transactions
- def validate_pinless_debit_card(creditcard, options = {})
- requires!(options, :order_id)
- commit(build_validate_pinless_debit_request(creditcard, options), :validate_pinless_debit_card, nil, options)
- end
-
def supports_scrubbing?
true
end
def scrub(transcript)
@@ -289,10 +280,11 @@
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_other_tax(xml, 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)
add_threeds_services(xml, options)
@@ -347,10 +339,11 @@
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_other_tax(xml, 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)
add_airline_data(xml, options)
@@ -360,11 +353,11 @@
add_partner_solution_id(xml)
else
add_purchase_service(xml, payment_method_or_reference, options)
add_threeds_services(xml, 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]
+ add_business_rules_data(xml, payment_method_or_reference, options)
add_stored_credential_subsequent_auth(xml, options)
add_issuer_additional_data(xml, options)
add_partner_solution_id(xml)
add_stored_credential_options(xml, options)
end
@@ -472,17 +465,10 @@
add_subscription(xml, options, reference)
add_subscription_retrieve_service(xml, options)
xml.target!
end
- def build_validate_pinless_debit_request(creditcard, options)
- xml = Builder::XmlMarkup.new indent: 2
- add_creditcard(xml, creditcard)
- add_validate_pinless_debit_service(xml)
- xml.target!
- end
-
def add_business_rules_data(xml, payment_method, options)
prioritized_options = [options, @options]
unless network_tokenization?(payment_method)
xml.tag! 'businessRules' do
@@ -792,19 +778,13 @@
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!('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!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
- end
+ add_auth_service(xml, payment_method, options)
+ xml.tag! 'ccCaptureService', { 'run' => 'true' } do
+ xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
end
end
def add_void_service(xml, request_id, request_token)
xml.tag! 'voidService', { 'run' => 'true' } do
@@ -909,14 +889,10 @@
xml.tag!('planType', options[:installment_plan_type]) if options[:installment_plan_type]
xml.tag!('firstInstallmentDate', options[:first_installment_date]) if options[:first_installment_date]
end
end
- def add_validate_pinless_debit_service(xml)
- xml.tag! 'pinlessDebitValidateService', { 'run' => 'true' }
- end
-
def add_threeds_services(xml, options)
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! 'signedPARes', options[:pares]
@@ -1074,9 +1050,13 @@
elsif response[:reasonCode] == '102' && response[:invalidField]
"#{response[:message]}: #{response[:invalidField]}"
else
response[:message]
end
+ end
+
+ def eligible_for_zero_auth?(payment_method, options = {})
+ payment_method.is_a?(CreditCard) && options[:zero_amount_auth]
end
end
end
end