Skip to content

Loading…

Pass cvv on card update #3

Merged
merged 1 commit into from

2 participants

@shayfrendt

Always passing the CVV allows for "updating a credit card and explicitly
verifying the card" at the same time:
https://www.braintreepayments.com/docs/ruby/general/card_verification#credit_card_api

@shayfrendt shayfrendt Always pass CVV on card update for Braintree Blue
Always passing the CVV allows for "updating a credit card and explicitly
verifying the card" at the same time:
https://www.braintreepayments.com/docs/ruby/general/card_verification#credit_card_api
0836d0c
@brentmc79

Looks good. Merge it.

@shayfrendt shayfrendt merged commit 9a0b738 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 15, 2012
  1. @shayfrendt

    Always pass CVV on card update for Braintree Blue

    shayfrendt committed
    Always passing the CVV allows for "updating a credit card and explicitly
    verifying the card" at the same time:
    https://www.braintreepayments.com/docs/ruby/general/card_verification#credit_card_api
View
1 lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -105,6 +105,7 @@ def update(vault_id, creditcard, options = {})
credit_card_params = merge_credit_card_options({
:credit_card => {
:number => creditcard.number,
+ :cvv => creditcard.verification_value,
:expiration_month => creditcard.month.to_s.rjust(2, "0"),
:expiration_year => creditcard.year.to_s
}
View
30 test/unit/gateways/braintree_blue_test.rb
@@ -150,6 +150,36 @@ def test_store_with_billing_address_options
@gateway.store(credit_card("41111111111111111111"), :billing_address => billing_address)
end
+ def test_update_with_cvv
+ stored_credit_card = mock(:token => "token", :default? => true)
+ customer = mock(:credit_cards => [stored_credit_card], :id => '123')
+ Braintree::Customer.stubs(:find).with('vault_id').returns(customer)
+ BraintreeBlueGateway.any_instance.stubs(:customer_hash)
+
+ result = Braintree::SuccessfulResult.new(:customer => customer)
+ Braintree::Customer.expects(:update).with do |vault, params|
+ assert_equal "567", params[:credit_card][:cvv]
+ [vault, params]
+ end.returns(result)
+
+ @gateway.update('vault_id', credit_card("41111111111111111111", :verification_value => "567"))
+ end
+
+ def test_update_with_verify_card_true
+ stored_credit_card = mock(:token => "token", :default? => true)
+ customer = mock(:credit_cards => [stored_credit_card], :id => '123')
+ Braintree::Customer.stubs(:find).with('vault_id').returns(customer)
+ BraintreeBlueGateway.any_instance.stubs(:customer_hash)
+
+ result = Braintree::SuccessfulResult.new(:customer => customer)
+ Braintree::Customer.expects(:update).with do |vault, params|
+ assert_equal true, params[:credit_card][:options][:verify_card]
+ [vault, params]
+ end.returns(result)
+
+ @gateway.update('vault_id', credit_card("41111111111111111111"), :verify_card => true)
+ end
+
def test_merge_credit_card_options_ignores_bad_option
params = {:first_name => 'John', :credit_card => {:cvv => '123'}}
options = {:verify_card => true, :bogus => 'ignore me'}
Something went wrong with that request. Please try again.