lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.90.0 vs lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.91.0
- old
+ new
@@ -31,11 +31,11 @@
@username, @password, @merchant_account = options.values_at(:username, :password, :merchant_account)
super
end
def purchase(money, payment, options={})
- if options[:execute_threed]
+ if options[:execute_threed] || options[:threed_dynamic]
authorize(money, payment, options)
else
MultiResponse.run do |r|
r.process { authorize(money, payment, options) }
r.process { capture(money, r.authorization, options) }
@@ -50,11 +50,11 @@
add_payment(post, payment)
add_extra_data(post, payment, options)
add_shopper_interaction(post, payment, options)
add_address(post, options)
add_installments(post, options) if options[:installments]
- add_3ds(post, options) if options[:execute_threed]
+ add_3ds(post, options)
commit('authorise', post)
end
def capture(money, authorization, options={})
post = init_post(options)
@@ -108,28 +108,32 @@
private
AVS_MAPPING = {
'0' => 'R', # Unknown
- '1' => 'A', # Address matches, postal code doesn't
- '2' => 'N', # Neither postal code nor address match
- '3' => 'R', # AVS unavailable
- '4' => 'E', # AVS not supported for this card type
- '5' => 'U', # No AVS data provided
- '6' => 'Z', # Postal code matches, address doesn't match
- '7' => 'D', # Both postal code and address match
- '8' => 'U', # Address not checked, postal code unknown
- '9' => 'B', # Address matches, postal code unknown
- '10' => 'N', # Address doesn't match, postal code unknown
- '11' => 'U', # Postal code not checked, address unknown
- '12' => 'B', # Address matches, postal code not checked
- '13' => 'U', # Address doesn't match, postal code not checked
- '14' => 'P', # Postal code matches, address unknown
- '15' => 'P', # Postal code matches, address not checked
- '16' => 'N', # Postal code doesn't match, address unknown
+ '1' => 'A', # Address matches, postal code doesn't
+ '2' => 'N', # Neither postal code nor address match
+ '3' => 'R', # AVS unavailable
+ '4' => 'E', # AVS not supported for this card type
+ '5' => 'U', # No AVS data provided
+ '6' => 'Z', # Postal code matches, address doesn't match
+ '7' => 'D', # Both postal code and address match
+ '8' => 'U', # Address not checked, postal code unknown
+ '9' => 'B', # Address matches, postal code unknown
+ '10' => 'N', # Address doesn't match, postal code unknown
+ '11' => 'U', # Postal code not checked, address unknown
+ '12' => 'B', # Address matches, postal code not checked
+ '13' => 'U', # Address doesn't match, postal code not checked
+ '14' => 'P', # Postal code matches, address unknown
+ '15' => 'P', # Postal code matches, address not checked
+ '16' => 'N', # Postal code doesn't match, address unknown
'17' => 'U', # Postal code doesn't match, address not checked
- '18' => 'I' # Neither postal code nor address were checked
+ '18' => 'I', # Neither postal code nor address were checked
+ '20' => 'V', # Name, address and postal code matches.
+ '23' => 'F', # Postal code matches, name doesn't match.
+ '24' => 'H', # Both postal code and address matches, name doesn't match.
+ '25' => 'T' # Address matches, name doesn't match.
}
CVC_MAPPING = {
'0' => 'P', # Unknown
'1' => 'M', # Matches
@@ -185,11 +189,11 @@
post[:card][:billingAddress] = {}
post[:card][:billingAddress][:street] = address[:address1] || 'N/A'
post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
post[:card][:billingAddress][:city] = address[:city] || 'N/A'
- post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state]
+ post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
post[:card][:billingAddress][:country] = address[:country] if address[:country]
end
end
def add_invoice(post, money, options)
@@ -270,11 +274,12 @@
value: options[:installments]
}
end
def add_3ds(post, options)
- post[:additionalData] = { executeThreeD: 'true' }
+ return unless options[:execute_threed] || options[:threed_dynamic]
post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
end
def parse(body)
return {} if body.blank?
JSON.parse(body)