Friday, February 11, 2011

AuthorizeNetCimGateway create_customer_profile and update_customer_payment_profile not supporting validation mode

ActiveMerchant::Billing::AuthorizeNetCimGateway "create_customer_profile" and "update_customer_payment_profile" method does not support the "validation_mode" option, which tells Authorize.net how to perform validations against the optionally provided payment profile(s) (See bottom of page 14 of CIM XML implementation guide - "validationMode"). The patch below implements the support for the missing option in both methods.


module ActiveMerchant
module Billing
class AuthorizeNetCimGateway < Gateway

alias :original_build_create_customer_profile_request :build_create_customer_profile_request
def build_create_customer_profile_request(xml, options)
add_profile( xml, options[:profile] )
xml.tag!( 'validationMode', CIM_VALIDATION_MODES[ options[:validation_mode] ] ) if options[:validation_mode]
xml.target!
end

alias :original_build_update_customer_payment_profile_request :build_update_customer_payment_profile_request
def build_update_customer_payment_profile_request(xml, options)
xml.tag!('customerProfileId', options[:customer_profile_id])
xml.tag!('paymentProfile') do
add_payment_profile(xml, options[:payment_profile])
end
xml.tag!( 'validationMode', CIM_VALIDATION_MODES[ options[:validation_mode] ] ) if options[:validation_mode]
xml.target!
end
end
end
end

0 Comments:

Post a Comment

<< Home