Hola a todos,
tengo un problema con la verificación del CVV (Card Verification
Value),
estoy usando ActiveMerchant como plugin y Moneris como el gateway,
funciona
bastante bien la cosa el único problema es que parece ser que no está
validando el CVV, le paso cualquier cosa y me sigue validando las
tarjetas
:(. He buscado por todos lados y nada, compré el peepcode de
ActiveMerchant,
và los railscast de R. Bates, lo más cercano lo encontré en este thread
[1].
Aca el código que considero relevante:
Aunque esto no creo que sea necesario, pero lo puse por las dudas
#environment.rb
. . .
require ‘active_merchant’
ActiveMerchant::Billing::CreditCard.require_verification_value = true
. . .
order.rb
. . .
def process(order)
Base.mode = :test
gateway = MonerisGateway.new(:login => "store2", :password =>
“yesguy”)
credit_card = CreditCard.new(
:type => order[:card_type], :number => order[:card_number],
:month => order[:card_expiration_month], :year =>
order[:card_expiration_year],
:first_name => order[:card_name].split(’ ‘).first,
:last_name =>
order[:card_name].split(’ ').last,
:verification_value => ‘1000’
:verification_value => order[:card_verification_code]
)
if credit_card.valid?
billing_datas = {
:name => order[:billing_name],
:address1 => order[:billing_address], :address2 =>
order[:billing_address2],
:phone => order[:contact_phone_number],
:city => order[:billing_city], :state =>
order[:billing_state],
:country => order[:billing_country], # Be sure that here
will be the country code instead the country name
:zip => order[:billing_zip]
}
options = {
:order_id => '36012-' + self.id.to_s,
:billing_address => billing_datas,
:email => order[:contact_email],
:subtotal => total,
:shipping => shipping_price,
:tax1 => taxes,
:custom => special_instructions
}
response = gateway.authorize(pennis , credit_card, options)
response = gateway.authorize(1000 , credit_card, options)
response = gateway.authorize(1036 , credit_card, options)
# Pennis Simulation code to CVV verification
# 10.35 APPROVED M
# 10.36 CAPTURE declined N
# For debug
cvv_result = response.cvv_result
puts " ---------------------- "
puts cvv_result
puts cvv_result[:code]
puts cvv_result[:message]
puts " ----------------------"
if response.success?
self.status = 'processed'
else
puts response.message # for debug
self.status = 'failed'
self.error_message = response.message
self.decline_times += 1 if
self.error_message.include?(‘ecline’)
end
else # Credit Card is not valid
self.error_message = “Error: credit card is not valid.
#{credit_card.errors.full_messages.join('. ')}”
end
self.save
end
. . .
response.cvv_result siempre es un hash que tiene nil :(. Gracias de
antemano
por cualquier ayuda,
Franco.