spec/integration/braintree/credit_card_spec.rb in braintree-3.3.0 vs spec/integration/braintree/credit_card_spec.rb in braintree-3.4.0

- old
+ new

@@ -44,11 +44,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_month => "05", - :expiration_year => "2012" + :expiration_year => "2012", ) result.success?.should == true credit_card = result.credit_card credit_card.expiration_month.should == "05" credit_card.expiration_year.should == "2012" @@ -61,11 +61,11 @@ result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2009", :cvv => "100", - :token => token + :token => token, ) result.success?.should == true credit_card = result.credit_card credit_card.token.should == token credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6] @@ -79,11 +79,11 @@ credit_card = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :billing_address_id => address.id + :billing_address_id => address.id, ).credit_card credit_card.billing_address.id.should == address.id credit_card.billing_address.first_name.should == "Bobby" credit_card.billing_address.last_name.should == "Tables" @@ -93,22 +93,22 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :options => {} + :options => {}, ) result.success?.should == true end it "verifies the credit card if options[verify_card]=true" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) result.success?.should == false result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined result.credit_card_verification.processor_response_code.should == "2000" result.credit_card_verification.processor_response_text.should == "Do Not Honor" @@ -122,11 +122,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :options => {:verify_card => true, :verification_amount => "100.00"} + :options => {:verify_card => true, :verification_amount => "100.00"}, ) result.success?.should == false result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined result.credit_card_verification.processor_response_code.should == "2000" result.credit_card_verification.processor_response_text.should == "Do Not Honor" @@ -143,18 +143,18 @@ :cardholder_name => "Original Holder", :customer_id => customer.id, :cvv => "123", :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2020", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) verification = credit_card.verification verification.risk_data.id.should_not be_nil verification.risk_data.decision.should_not be_nil verification.risk_data.decision_reasons.should_not be_nil - verification.risk_data.device_data_captured.should_not be_nil - verification.risk_data.fraud_service_provider.should_not be_nil + expect(verification.risk_data).to respond_to(:device_data_captured) + expect(verification.risk_data).to respond_to(:fraud_service_provider) expect(verification.risk_data).to respond_to(:transaction_risk_score) end end it "exposes the gateway rejection reason on verification" do @@ -171,11 +171,11 @@ result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2009", :cvv => "200", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) result.success?.should == false result.credit_card_verification.gateway_rejection_reason.should == Braintree::CreditCardVerification::GatewayRejectionReason::CVV ensure Braintree::Configuration.merchant_id = old_merchant @@ -188,11 +188,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :options => {:verify_card => true, :verification_amount => "1.01"} + :options => {:verify_card => true, :verification_amount => "1.01"}, ) result.success?.should == false result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined result.credit_card_verification.processor_response_code.should == "2000" result.credit_card_verification.processor_response_text.should == "Do Not Honor" @@ -209,11 +209,11 @@ :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId - } + }, ) result.success?.should == false result.credit_card_verification.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId end @@ -221,30 +221,30 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa, :expiration_date => "05/2009", - :options => {:verify_card => false} + :options => {:verify_card => false}, ) result.success?.should == true end it "validates presence of three_d_secure_version in 3ds pass thru params" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :payment_method_nonce => Braintree::Test::Nonce::Transactable, :three_d_secure_pass_thru => { - :eci_flag => '02', - :cavv => 'some_cavv', - :xid => 'some_xid', - :authentication_response => 'Y', - :directory_response => 'Y', - :cavv_algorithm => '2', - :ds_transaction_id => 'some_ds_transaction_id', + :eci_flag => "02", + :cavv => "some_cavv", + :xid => "some_xid", + :authentication_response => "Y", + :directory_response => "Y", + :cavv_algorithm => "2", + :ds_transaction_id => "some_ds_transaction_id", }, - :options => {:verify_card => true} + :options => {:verify_card => true}, ) expect(result).not_to be_success error = result.errors.for(:verification).first expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsRequired) expect(error.message).to eq("ThreeDSecureVersion is required.") @@ -254,31 +254,31 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :payment_method_nonce => Braintree::Test::Nonce::Transactable, :three_d_secure_pass_thru => { - :eci_flag => '02', - :cavv => 'some_cavv', - :xid => 'some_xid', - :three_d_secure_version => '1.0.2', - :authentication_response => 'Y', - :directory_response => 'Y', - :cavv_algorithm => '2', - :ds_transaction_id => 'some_ds_transaction_id', + :eci_flag => "02", + :cavv => "some_cavv", + :xid => "some_xid", + :three_d_secure_version => "1.0.2", + :authentication_response => "Y", + :directory_response => "Y", + :cavv_algorithm => "2", + :ds_transaction_id => "some_ds_transaction_id", }, - :options => {:verify_card => true} + :options => {:verify_card => true}, ) result.success?.should == true end it "returns 3DS info on cc verification" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication, - :options => {:verify_card => true} + :options => {:verify_card => true}, ) result.success?.should == true three_d_secure_info = result.credit_card.verification.three_d_secure_info three_d_secure_info.enrolled.should == "Y" @@ -302,11 +302,11 @@ :billing_address => { :street_address => "123 Abc Way", :locality => "Chicago", :region => "Illinois", :postal_code => "60622" - } + }, ) result.success?.should == true credit_card = result.credit_card credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6] credit_card.billing_address.street_address.should == "123 Abc Way" @@ -321,11 +321,11 @@ :billing_address => { :country_name => "United States of America", :country_code_alpha2 => "US", :country_code_alpha3 => "USA", :country_code_numeric => "840" - } + }, ) result.success?.should == true credit_card = result.credit_card credit_card.billing_address.country_name.should == "United States of America" credit_card.billing_address.country_code_alpha2.should == "US" @@ -340,43 +340,43 @@ :number => Braintree::Test::CreditCardNumbers::MasterCard, :expiration_date => "12/2009", :billing_address => { :country_name => "Mexico", :country_code_alpha2 => "US" - } + }, ) result.success?.should == false result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry) end it "returns an error response if unsuccessful" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "invalid_date" + :expiration_date => "invalid_date", ) result.success?.should == false result.errors.for(:credit_card).on(:expiration_date)[0].message.should == "Expiration date is invalid." end it "can set the default flag" do customer = Braintree::Customer.create! card1 = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2009" + :expiration_date => "05/2009", ).credit_card card1.should be_default card2 = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2009", :options => { :make_default => true - } + }, ).credit_card card2.should be_default Braintree::CreditCard.find(card1.token).should_not be_default end @@ -401,11 +401,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Yes end @@ -413,11 +413,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Healthcare, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.healthcare.should == Braintree::CreditCard::Healthcare::Yes credit_card.product_id.should == "J3" end @@ -426,11 +426,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::DurbinRegulated, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes end @@ -438,11 +438,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::CountryOfIssuance, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.country_of_issuance.should == Braintree::Test::CreditCardDefaults::CountryOfIssuance end @@ -450,11 +450,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::IssuingBank, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.issuing_bank.should == Braintree::Test::CreditCardDefaults::IssuingBank end @@ -462,11 +462,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Payroll, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.payroll.should == Braintree::CreditCard::Payroll::Yes credit_card.product_id.should == "MSA" end @@ -475,11 +475,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Debit, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.debit.should == Braintree::CreditCard::Debit::Yes end @@ -487,11 +487,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Commercial, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.commercial.should == Braintree::CreditCard::Commercial::Yes end @@ -499,11 +499,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::No, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.prepaid.should == Braintree::CreditCard::Prepaid::No credit_card.commercial.should == Braintree::CreditCard::Prepaid::No credit_card.payroll.should == Braintree::CreditCard::Prepaid::No @@ -517,11 +517,11 @@ customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Unknown, :expiration_date => "05/2014", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) credit_card = result.credit_card credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Unknown credit_card.commercial.should == Braintree::CreditCard::Prepaid::Unknown credit_card.payroll.should == Braintree::CreditCard::Prepaid::Unknown @@ -538,11 +538,11 @@ describe "venmo_sdk_payment_method_code" do it "can pass a venmo sdk payment method code" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, - :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode + :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode, ) result.success?.should == true result.credit_card.venmo_sdk?.should == false result.credit_card.bin.should == "400934" result.credit_card.last_4.should == "1881" @@ -550,11 +550,11 @@ it "success? returns false when given an invalid venmo sdk payment method code" do customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, - :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode + :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode, ) result.success?.should == false result.message.should == "Invalid VenmoSDK payment method code" result.errors.first.code.should == "91727" @@ -569,11 +569,11 @@ :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2009", :cvv => "100", :options => { :venmo_sdk_session => Braintree::Test::VenmoSDK::Session - } + }, ) result.success?.should == true result.credit_card.venmo_sdk?.should == false end @@ -584,11 +584,11 @@ :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2009", :cvv => "100", :options => { :venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession - } + }, ) result.success?.should == true result.credit_card.venmo_sdk?.should == false end end @@ -600,16 +600,16 @@ :credit_card => { :number => "4111111111111111", :expiration_month => "11", :expiration_year => "2099", }, - :share => true + :share => true, ) customer = Braintree::Customer.create! result = Braintree::CreditCard.create( :customer_id => customer.id, - :payment_method_nonce => nonce + :payment_method_nonce => nonce, ) result.success?.should == true credit_card = result.credit_card credit_card.bin.should == "411111" @@ -642,11 +642,11 @@ :expiration_year => "2099", :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, :verification_account_type => "debit", - } + }, ) expect(result).to be_success end @@ -659,11 +659,11 @@ :expiration_year => "2099", :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, :verification_account_type => "credit", - } + }, ) expect(result).to be_success end @@ -675,11 +675,11 @@ :expiration_year => "2099", :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, :verification_account_type => "ach", - } + }, ) expect(result).to_not be_success expect(result.errors.for(:credit_card).for(:options).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::CreditCard::VerificationAccountTypeIsInvalid end @@ -691,11 +691,11 @@ :expiration_month => "11", :expiration_year => "2099", :options => { :verify_card => true, :verification_account_type => "credit", - } + }, ) expect(result).to_not be_success expect(result.errors.for(:credit_card).for(:options).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::CreditCard::VerificationAccountTypeNotSupported end @@ -707,11 +707,11 @@ customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :customer_id => customer.id, :cardholder_name => "Adam Davis", :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2009" + :expiration_date => "05/2009", ) credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6] credit_card.cardholder_name.should == "Adam Davis" credit_card.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1] credit_card.expiration_date.should == "05/2009" @@ -721,11 +721,11 @@ customer = Braintree::Customer.create! expect do Braintree::CreditCard.create!( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "invalid_date" + :expiration_date => "invalid_date", ) end.to raise_error(Braintree::ValidationsFailed) end end @@ -733,15 +733,15 @@ it "creates a credit transaction using the payment method token, returning a result object" do customer = Braintree::Customer.create!( :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2010" - } + }, ) result = Braintree::CreditCard.credit( customer.credit_cards[0].token, - :amount => "100.00" + :amount => "100.00", ) result.success?.should == true result.transaction.amount.should == BigDecimal("100.00") result.transaction.type.should == "credit" result.transaction.customer_details.id.should == customer.id @@ -756,15 +756,15 @@ it "creates a credit transaction using the payment method token, returning the transaction" do customer = Braintree::Customer.create!( :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2010" - } + }, ) transaction = Braintree::CreditCard.credit!( customer.credit_cards[0].token, - :amount => "100.00" + :amount => "100.00", ) transaction.amount.should == BigDecimal("100.00") transaction.type.should == "credit" transaction.customer_details.id.should == customer.id transaction.credit_card_details.token.should == customer.credit_cards[0].token @@ -780,17 +780,17 @@ credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :cvv => "123", :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) update_result = Braintree::CreditCard.update(credit_card.token, :cardholder_name => "New Holder", :cvv => "456", :number => Braintree::Test::CreditCardNumbers::MasterCard, - :expiration_date => "06/2013" + :expiration_date => "06/2013", ) update_result.success?.should == true update_result.credit_card.should == credit_card updated_credit_card = update_result.credit_card updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6] @@ -804,24 +804,24 @@ credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :cvv => "123", :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) result = Braintree::CreditCard.update(credit_card.token, :payment_method_nonce => Braintree::Test::Nonce::Transactable, :three_d_secure_pass_thru => { - :eci_flag => '02', - :cavv => 'some_cavv', - :xid => 'some_xid', - :authentication_response => 'Y', - :directory_response => 'Y', - :cavv_algorithm => '2', - :ds_transaction_id => 'some_ds_transaction_id', + :eci_flag => "02", + :cavv => "some_cavv", + :xid => "some_xid", + :authentication_response => "Y", + :directory_response => "Y", + :cavv_algorithm => "2", + :ds_transaction_id => "some_ds_transaction_id", }, - :options => {:verify_card => true} + :options => {:verify_card => true}, ) expect(result).not_to be_success error = result.errors.for(:verification).first expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsRequired) expect(error.message).to eq("ThreeDSecureVersion is required.") @@ -832,25 +832,25 @@ credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :cvv => "123", :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) result = Braintree::CreditCard.update(credit_card.token, :payment_method_nonce => Braintree::Test::Nonce::Transactable, :three_d_secure_pass_thru => { - :eci_flag => '02', - :cavv => 'some_cavv', + :eci_flag => "02", + :cavv => "some_cavv", :three_d_secure_version=> "2.1.0", - :xid => 'some_xid', - :authentication_response => 'Y', - :directory_response => 'Y', - :cavv_algorithm => '2', - :ds_transaction_id => 'some_ds_transaction_id', + :xid => "some_xid", + :authentication_response => "Y", + :directory_response => "Y", + :cavv_algorithm => "2", + :ds_transaction_id => "some_ds_transaction_id", }, - :options => {:verify_card => true} + :options => {:verify_card => true}, ) result.success?.should == true end @@ -862,16 +862,16 @@ :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2012", :billing_address => { :street_address => "123 Nigeria Ave" - } + }, ) update_result = Braintree::CreditCard.update(credit_card.token, :billing_address => { :region => "IL" - } + }, ) update_result.success?.should == true updated_credit_card = update_result.credit_card updated_credit_card.billing_address.region.should == "IL" updated_credit_card.billing_address.street_address.should == nil @@ -884,17 +884,17 @@ :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2012", :billing_address => { :street_address => "123 Nigeria Ave" - } + }, ) update_result = Braintree::CreditCard.update(credit_card.token, :billing_address => { :region => "IL", :options => {:update_existing => true} - } + }, ) update_result.success?.should == true updated_credit_card = update_result.credit_card updated_credit_card.billing_address.region.should == "IL" updated_credit_card.billing_address.street_address.should == "123 Nigeria Ave" @@ -907,20 +907,20 @@ :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2012", :billing_address => { :street_address => "123 Nigeria Ave" - } + }, ) update_result = Braintree::CreditCard.update(credit_card.token, :billing_address => { :country_name => "American Samoa", :country_code_alpha2 => "AS", :country_code_alpha3 => "ASM", :country_code_numeric => "016", :options => {:update_existing => true} - } + }, ) update_result.success?.should == true updated_credit_card = update_result.credit_card updated_credit_card.billing_address.country_name.should == "American Samoa" updated_credit_card.billing_address.country_code_alpha2.should == "AS" @@ -932,16 +932,16 @@ it "can pass expiration_month and expiration_year" do customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) update_result = Braintree::CreditCard.update(credit_card.token, :number => Braintree::Test::CreditCardNumbers::MasterCard, :expiration_month => "07", - :expiration_year => "2011" + :expiration_year => "2011", ) update_result.success?.should == true update_result.credit_card.should == credit_card update_result.credit_card.expiration_month.should == "07" update_result.credit_card.expiration_year.should == "2011" @@ -953,18 +953,18 @@ credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :cvv => "123", :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) update_result = Braintree::CreditCard.update(credit_card.token, :cardholder_name => "New Holder", :cvv => "456", :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard, :expiration_date => "06/2013", - :options => {:verify_card => true} + :options => {:verify_card => true}, ) update_result.success?.should == false update_result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined update_result.credit_card_verification.gateway_rejection_reason.should be_nil end @@ -985,11 +985,11 @@ :extended_address => "Apt Old", :locality => "Old City", :region => "Old State", :postal_code => "12345", :country_name => "Canada" - } + }, ) result = Braintree::CreditCard.update(credit_card.token, :options => {:verify_card => false}, :billing_address => { :first_name => "New First Name", @@ -999,11 +999,11 @@ :extended_address => "Apt New", :locality => "New City", :region => "New State", :postal_code => "56789", :country_name => "United States of America" - } + }, ) result.success?.should == true address = result.credit_card.billing_address address.first_name.should == "New First Name" address.last_name.should == "New Last Name" @@ -1020,32 +1020,32 @@ customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) update_result = Braintree::CreditCard.update(credit_card.token, :cardholder_name => "New Holder", :number => "invalid", - :expiration_date => "05/2014" + :expiration_date => "05/2014", ) update_result.success?.should == false update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits." end it "can update the default" do customer = Braintree::Customer.create! card1 = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2009" + :expiration_date => "05/2009", ).credit_card card2 = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2009" + :expiration_date => "05/2009", ).credit_card card1.should be_default card2.should_not be_default @@ -1099,16 +1099,16 @@ customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) updated_credit_card = Braintree::CreditCard.update!(credit_card.token, :cardholder_name => "New Holder", :number => Braintree::Test::CreditCardNumbers::MasterCard, - :expiration_date => "06/2013" + :expiration_date => "06/2013", ) updated_credit_card.token.should == credit_card.token updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6] updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1] updated_credit_card.expiration_date.should == "06/2013" @@ -1120,17 +1120,17 @@ customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) expect do Braintree::CreditCard.update!(credit_card.token, :cardholder_name => "New Holder", :number => Braintree::Test::CreditCardNumbers::MasterCard, - :expiration_date => "invalid/date" + :expiration_date => "invalid/date", ) end.to raise_error(Braintree::ValidationsFailed) end end @@ -1138,11 +1138,11 @@ it "deletes the credit card" do customer = Braintree::Customer.create.customer result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) result.success?.should == true credit_card = result.credit_card Braintree::CreditCard.delete(credit_card.token).should == true @@ -1158,11 +1158,11 @@ (110 - Braintree::CreditCard.expired.maximum_size).times do Braintree::CreditCard.create!( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "01/#{Time.now.year - 3}" + :expiration_date => "01/#{Time.now.year - 3}", ) end collection = Braintree::CreditCard.expired collection.maximum_size.should > 100 @@ -1189,29 +1189,29 @@ (110 - Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1)).maximum_size).times do Braintree::CreditCard.create!( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "01/2010" + :expiration_date => "01/2010", ) end collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1)) collection.maximum_size.should > 100 - credit_card_ids = collection.map {|c| c.token }.uniq.compact + credit_card_ids = collection.map { |c| c.token }.uniq.compact credit_card_ids.size.should == collection.maximum_size end end describe "self.find" do it "finds the payment method with the given token" do customer = Braintree::Customer.create.customer result = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) result.success?.should == true credit_card = Braintree::CreditCard.find(result.credit_card.token) credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6] credit_card.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1] @@ -1222,17 +1222,17 @@ it "returns associated subscriptions with the credit card" do customer = Braintree::Customer.create.customer credit_card = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ).credit_card subscription = Braintree::Subscription.create( :payment_method_token => credit_card.token, :plan_id => "integration_trialless_plan", - :price => "1.00" + :price => "1.00", ).subscription found_card = Braintree::CreditCard.find(credit_card.token) found_card.subscriptions.first.id.should == subscription.id found_card.subscriptions.first.plan_id.should == "integration_trialless_plan" @@ -1272,11 +1272,11 @@ :credit_card => { :number => "4111111111111111", :expiration_month => "11", :expiration_year => "2099", }, - :client_token_options => {:customer_id => customer.id} + :client_token_options => {:customer_id => customer.id}, ) credit_card = Braintree::CreditCard.from_nonce(nonce) customer = Braintree::Customer.find(customer.id) credit_card.should == customer.credit_cards.first @@ -1286,11 +1286,11 @@ nonce = nonce_for_new_payment_method( :credit_card => { :number => "4111111111111111", :expiration_month => "11", :expiration_year => "2099", - } + }, ) expect do Braintree::CreditCard.from_nonce(nonce) end.to raise_error(Braintree::NotFoundError) end @@ -1301,11 +1301,11 @@ :credit_card => { :number => "4111111111111111", :expiration_month => "11", :expiration_year => "2099", }, - :client_token_options => {:customer_id => customer.id} + :client_token_options => {:customer_id => customer.id}, ) Braintree::CreditCard.from_nonce(nonce) expect do Braintree::CreditCard.from_nonce(nonce) @@ -1317,11 +1317,11 @@ it "creates a sale transaction using the credit card, returning a result object" do customer = Braintree::Customer.create!( :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2010" - } + }, ) result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00") result.success?.should == true result.transaction.amount.should == BigDecimal("100.00") @@ -1336,17 +1336,17 @@ it "allows passing a cvv in addition to the token" do customer = Braintree::Customer.create!( :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2010" - } + }, ) result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00", :credit_card => { :cvv => "301" - } + }, ) result.success?.should == true result.transaction.amount.should == BigDecimal("100.00") result.transaction.type.should == "sale" @@ -1360,11 +1360,11 @@ it "creates a sale transaction using the credit card, returning the transaction" do customer = Braintree::Customer.create!( :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, :expiration_date => "05/2010" - } + }, ) transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00") transaction.amount.should == BigDecimal("100.00") transaction.type.should == "sale" transaction.customer_details.id.should == customer.id @@ -1380,11 +1380,11 @@ customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create!( :cardholder_name => "Original Holder", :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2012" + :expiration_date => "05/2012", ) credit_card.nonce.should_not be_nil end end @@ -1398,10 +1398,10 @@ it "should find a non-network tokenized credit card" do customer = Braintree::Customer.create! credit_card = Braintree::CreditCard.create( :customer_id => customer.id, :number => Braintree::Test::CreditCardNumbers::Visa, - :expiration_date => "05/2009" + :expiration_date => "05/2009", ).credit_card credit_card_vaulted = Braintree::CreditCard.find(credit_card.token) credit_card_vaulted.is_network_tokenized?.should == false end end