Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #96 from viniciusnz/master
Browse files Browse the repository at this point in the history
Allow no CVV in credit card payments
  • Loading branch information
wvanbergen committed Oct 21, 2014
2 parents 35b01b9 + bd146ea commit 82b0803
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/adyen/api/payment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ def card_partial
if @params[:card] && @params[:card][:encrypted] && @params[:card][:encrypted][:json]
ENCRYPTED_CARD_PARTIAL % [@params[:card][:encrypted][:json]]
else
validate_parameters!(:card => [:holder_name, :number, :cvc, :expiry_year, :expiry_month])
card = @params[:card].values_at(:holder_name, :number, :cvc, :expiry_year)
validate_parameters!(:card => [:holder_name, :number, :expiry_year, :expiry_month])
card = @params[:card].values_at(:holder_name, :number, :expiry_year)
card << @params[:card][:expiry_month].to_i
card << (['', nil].include?(@params[:card][:cvc]) ? '' : (CARD_CVC_PARTIAL % @params[:card][:cvc]))
CARD_PARTIAL % card
end
end
Expand Down
7 changes: 6 additions & 1 deletion lib/adyen/api/templates/payment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ def modification_request_with_amount(method)
<payment:card>
<payment:holderName>%s</payment:holderName>
<payment:number>%s</payment:number>
<payment:cvc>%s</payment:cvc>
<payment:expiryYear>%s</payment:expiryYear>
<payment:expiryMonth>%02d</payment:expiryMonth>
%s
</payment:card>
EOXML

# @private
CARD_CVC_PARTIAL = <<-EOXML
<payment:cvc>%s</payment:cvc>
EOXML

# @private
ONE_CLICK_CARD_PARTIAL = <<-EOXML
<payment:card>
Expand Down
2 changes: 1 addition & 1 deletion spec/api/payment_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
it_should_validate_request_parameters :merchant_account,
:reference,
:amount => [:currency, :value],
:card => [:holder_name, :number, :cvc, :expiry_year, :expiry_month]
:card => [:holder_name, :number, :expiry_year, :expiry_month]

it_should_validate_request_param(:shopper) do
@payment.params[:recurring] = true
Expand Down

0 comments on commit 82b0803

Please sign in to comment.