spec/integration/braintree/transaction_spec.rb in braintree-3.3.0 vs spec/integration/braintree/transaction_spec.rb in braintree-3.4.0
- old
+ new
@@ -22,21 +22,21 @@
:shipping => {
:country_name => "Bhutan",
:country_code_alpha2 => "BT",
:country_code_alpha3 => "BTN",
:country_code_numeric => "064"
- }
+ },
)
result.success?.should == true
clone_result = Braintree::Transaction.clone_transaction(
result.transaction.id,
:amount => "112.44",
:channel => "MyShoppingCartProvider",
:options => {
:submit_for_settlement => false
- }
+ },
)
clone_result.success?.should == true
transaction = clone_result.transaction
@@ -65,11 +65,11 @@
result = Braintree::Transaction.sale(
:amount => "112.44",
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/2012"
- }
+ },
)
result.success?.should be(true)
clone_result = Braintree::Transaction.clone_transaction(result.transaction.id, :amount => "112.44", :options => {:submit_for_settlement => true})
@@ -82,11 +82,11 @@
transaction = Braintree::Transaction.credit!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.clone_transaction(transaction.id, :amount => "112.44")
result.success?.should be(false)
result.errors.for(:transaction).on(:base).first.code.should == Braintree::ErrorCodes::Transaction::CannotCloneCredit
@@ -98,11 +98,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "112.44", :options => {:submit_for_settlement => false})
clone_transaction.id.should_not == transaction.id
end
@@ -110,11 +110,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
expect do
clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "im not a number")
clone_transaction.id.should_not == transaction.id
end.to raise_error(Braintree::ValidationsFailed)
@@ -129,18 +129,18 @@
:type => "sale",
:amount => 1_00,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
:expiration_date => "05/2009"
- }
+ },
)
result.transaction.risk_data.should be_a(Braintree::RiskData)
result.transaction.risk_data.id.should_not be_nil
result.transaction.risk_data.decision.should_not be_nil
result.transaction.risk_data.decision_reasons.should_not be_nil
- result.transaction.risk_data.device_data_captured.should_not be_nil
- result.transaction.risk_data.fraud_service_provider.should_not be_nil
+ expect(result.transaction.risk_data).to respond_to(:device_data_captured)
+ expect(result.transaction.risk_data).to respond_to(:fraud_service_provider)
expect(result.transaction.risk_data).to respond_to(:transaction_risk_score)
end
end
it "handles validation errors for invalid risk data attributes" do
@@ -156,11 +156,11 @@
:customer_browser => "#{"1" * 300}",
:customer_device_id => "customer_device_id_0#{"1" * 300}",
:customer_ip => "192.168.0.1",
:customer_location_zip => "not-a-$#phone",
:customer_tenure => "20#{"0" * 500}"
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:risk_data).on(:customer_device_id).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerDeviceIdIsTooLong
result.errors.for(:transaction).for(:risk_data).on(:customer_location_zip).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerLocationZipInvalidCharacters
result.errors.for(:transaction).for(:risk_data).on(:customer_tenure).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerTenureIsTooLong
@@ -174,11 +174,11 @@
:type => "sale",
:amount => 1_00,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
:expiration_date => "05/2009"
- }
+ },
)
result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::CreditCard
end
end
@@ -250,11 +250,11 @@
:kind => Braintree::Transaction::AdditionalCharge::Other,
:amount => 150_00,
},
],
}
- }
+ },
)
result.success?.should be(true)
end
it "returns errors if validations on industry lodging data fails" do
@@ -277,19 +277,19 @@
:kind => "unknown",
:amount => 20_00,
},
],
}
- }
+ },
)
result.success?.should be(false)
invalid_folio = Braintree::ErrorCodes::Transaction::Industry::Lodging::FolioNumberIsInvalid
check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate
room_rate_format_is_invalid = Braintree::ErrorCodes::Transaction::Industry::Lodging::RoomRateFormatIsInvalid
invalid_additional_charge_kind = Braintree::ErrorCodes::Transaction::Industry::AdditionalCharge::KindIsInvalid
- result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include *[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid]
- result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include *[invalid_additional_charge_kind]
+ result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include(*[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid])
+ result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include(*[invalid_additional_charge_kind])
end
end
context "for travel cruise" do
it "accepts valid industry data" do
@@ -307,11 +307,11 @@
:departure_date => "2014-07-01",
:lodging_check_in_date => "2014-07-07",
:lodging_check_out_date => "2014-07-07",
:lodging_name => "Royal Caribbean",
}
- }
+ },
)
result.success?.should be(true)
end
it "returns errors if validations on industry data fails" do
@@ -325,11 +325,11 @@
:industry => {
:industry_type => Braintree::Transaction::IndustryType::TravelAndCruise,
:data => {
:lodging_name => "Royal Caribbean"
}
- }
+ },
)
result.success?.should be(false)
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelCruise::TravelPackageIsInvalid]
end
end
@@ -399,11 +399,11 @@
:tax_amount => 10_00,
:endorsement_or_restrictions => "NOT REFUNDABLE"
}
]
}
- }
+ },
)
result.success?.should be(true)
end
it "returns errors if validations on industry data fails" do
@@ -423,11 +423,11 @@
{
:fare_amount => -1_23
}
]
}
- }
+ },
)
result.success?.should be(false)
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative]
result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative]
end
@@ -442,11 +442,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Elo,
:cvv => "737",
:expiration_date => "10/2020"
- }
+ },
)
result.success?.should == true
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
@@ -464,11 +464,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
@@ -490,11 +490,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
expect(result.success?).to eq(true)
expect(result.transaction.type).to eq("sale")
expect(result.transaction.amount).to eq(BigDecimal(Braintree::Test::TransactionAmounts::Authorize))
expect(result.transaction.processor_authorization_code).not_to be_nil
@@ -512,29 +512,29 @@
it "returns a successful result using an access token" do
oauth_gateway = Braintree::Gateway.new(
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
:merchant_public_id => "integration_merchant_id",
:scope => "read_write"
}).credentials.access_token
gateway = Braintree::Gateway.new(
:access_token => access_token,
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
result = gateway.transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
@@ -573,32 +573,32 @@
:customer_browser => "IE6",
:customer_device_id => "customer_device_id_012",
:customer_ip => "192.168.0.1",
:customer_location_zip => "91244",
:customer_tenure => "20",
- }
+ },
)
result.success?.should == true
end
it "accepts billing_address_id in place of billing_address" do
result = Braintree::Customer.create()
address_result = Braintree::Address.create(
:customer_id => result.customer.id,
- :country_code_alpha2 => "US"
+ :country_code_alpha2 => "US",
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:customer_id => result.customer.id,
:billing_address_id => address_result.address.id,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
end
@@ -607,11 +607,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Decline,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == false
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -626,11 +626,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::HardDecline,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == false
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -663,11 +663,11 @@
:country_code_numeric => "064"
},
:options => {
:add_billing_address_to_payment_method => true,
:store_in_vault => true
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.billing_details.country_name.should == "Botswana"
transaction.billing_details.country_code_alpha2.should == "BW"
@@ -693,11 +693,11 @@
:expiration_date => "05/2012"
},
:billing => {
:country_name => "Botswana",
:country_code_alpha2 => "US",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:billing).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
end
@@ -709,11 +709,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:billing => {
:country_code_alpha2 => "ZZ"
- }
+ },
)
result.success?.should == false
codes = result.errors.for(:transaction).for(:billing).on(:country_code_alpha2).map { |e| e.code }
codes.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
@@ -726,11 +726,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:billing => {
:country_code_alpha3 => "ZZZ"
- }
+ },
)
result.success?.should == false
codes = result.errors.for(:transaction).for(:billing).on(:country_code_alpha3).map { |e| e.code }
codes.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
@@ -743,11 +743,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:billing => {
:country_code_numeric => "FOO"
- }
+ },
)
result.success?.should == false
codes = result.errors.for(:transaction).for(:billing).on(:country_code_numeric).map { |e| e.code }
codes.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
@@ -774,11 +774,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:shipping => {
:phone_number => "123-234-3456=098765"
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:shipping).on(:phone_number).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::ShippingPhoneNumberIsInvalid)
end
@@ -790,11 +790,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:shipping => {
:shipping_method => "urgent"
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:shipping).on(:shipping_method).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::ShippingMethodIsInvalid)
end
@@ -806,11 +806,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:billing => {
:phone_number => "123-234-3456=098765"
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:billing).on(:phone_number).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::BillingPhoneNumberIsInvalid)
end
@@ -830,11 +830,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009",
:cvv => "200"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::CVV
ensure
Braintree::Configuration.merchant_id = old_merchant
@@ -845,30 +845,30 @@
it "exposes the application incomplete gateway rejection reason" do
gateway = Braintree::Gateway.new(
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
result = gateway.merchant.create(
:email => "name@email.com",
:country_code_alpha3 => "USA",
- :payment_methods => ["credit_card", "paypal"]
+ :payment_methods => ["credit_card", "paypal"],
)
gateway = Braintree::Gateway.new(
:access_token => result.credentials.access_token,
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
result = gateway.transaction.create(
:type => "sale",
:amount => "4000.00",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2020"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete
end
@@ -888,11 +888,11 @@
:street_address => "200 Fake Street"
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVS
ensure
Braintree::Configuration.merchant_id = old_merchant
@@ -918,11 +918,11 @@
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009",
:cvv => "200"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVSAndCVV
ensure
Braintree::Configuration.merchant_id = old_merchant
@@ -937,11 +937,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Fraud,
:expiration_date => "05/2017",
:cvv => "333"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::Fraud
end
end
@@ -952,11 +952,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::RiskThreshold,
:expiration_date => "05/2017",
:cvv => "333"
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
end
end
@@ -989,11 +989,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "05",
:expiration_year => "2011"
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.expiration_month.should == "05"
result.transaction.credit_card_details.expiration_year.should == "2011"
result.transaction.credit_card_details.expiration_date.should == "05/2011"
@@ -1001,11 +1001,11 @@
it "returns some error if customer_id is invalid" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Decline,
- :customer_id => 123456789
+ :customer_id => 123456789,
)
result.success?.should == false
result.errors.for(:transaction).on(:customer_id)[0].code.should == "91510"
result.message.should == "Customer ID is invalid."
end
@@ -1018,11 +1018,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:custom_fields => {
:store_me => "custom value"
- }
+ },
)
result.success?.should == true
result.transaction.custom_fields.should == {:store_me => "custom value"}
end
@@ -1033,11 +1033,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/2012"
},
:custom_fields => {
:store_me => ""
- }
+ },
)
result = Braintree::Transaction.find(create_result.transaction.id)
result.custom_fields.should == {}
@@ -1051,11 +1051,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:custom_fields => {
:invalid_key => "custom value"
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).on(:custom_fields)[0].message.should == "Custom field is invalid: invalid_key."
end
@@ -1070,11 +1070,11 @@
}
}
}
result = Braintree::Transaction.create(params[:transaction])
result.success?.should == false
- result.params.should == {:transaction => {:type => 'sale', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
+ result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
end
it "returns errors if validations fail (tests many errors at once for spec speed)" do
params = {
:transaction => {
@@ -1090,11 +1090,11 @@
:payment_method_token => "too long and doesn't belong to customer" * 250
}
}
result = Braintree::Transaction.create(params[:transaction])
result.success?.should == false
- result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
+ result.errors.for(:transaction).on(:base).map { |error| error.code }.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
result.errors.for(:transaction).on(:payment_method_token)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodTokenIsInvalid
result.errors.for(:transaction).on(:type)[0].code.should == Braintree::ErrorCodes::Transaction::TypeIsInvalid
end
@@ -1121,11 +1121,11 @@
:amount => "0.20",
:options => {
:credit_card => {
:account_type => "credit",
}
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountNotSupportedByProcessor
end
@@ -1165,17 +1165,17 @@
it "returns an error if the given payment method token doesn't belong to the customer" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:customer_id => customer.id,
- :payment_method_token => customer.credit_cards[0].token + "x"
+ :payment_method_token => customer.credit_cards[0].token + "x",
)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer
end
@@ -1183,20 +1183,20 @@
it "allows a new credit card to be used for an existing customer" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:customer_id => customer.id,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12"
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.masked_number.should == "401288******1881"
result.transaction.vault_credit_card.should be_nil
end
@@ -1204,21 +1204,21 @@
it "allows a new credit card to be used and stored in the vault" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:customer_id => customer.id,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :options => { :store_in_vault => true }
+ :options => {:store_in_vault => true},
)
result.success?.should == true
result.transaction.credit_card_details.masked_number.should == "401288******1881"
result.transaction.vault_credit_card.masked_number.should == "401288******1881"
result.transaction.credit_card_details.unique_number_identifier.should_not be_nil
@@ -1228,11 +1228,11 @@
it "snapshots plan, add_ons and discounts from subscription" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
result = Braintree::Subscription.create(
:payment_method_token => customer.credit_cards.first.token,
:plan_id => SpecHelper::TriallessPlan[:id],
@@ -1259,11 +1259,11 @@
:inherited_from_id => SpecHelper::Discount7,
:quantity => 2,
:never_expires => true
}
]
- }
+ },
)
result.success?.should be(true)
transaction = result.subscription.transactions.first
@@ -1300,33 +1300,33 @@
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:descriptor => {
- :name => '123*123456789012345678',
- :phone => '3334445555',
+ :name => "123*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com"
- }
+ },
)
result.success?.should == true
- result.transaction.descriptor.name.should == '123*123456789012345678'
- result.transaction.descriptor.phone.should == '3334445555'
- result.transaction.descriptor.url.should == 'ebay.com'
+ result.transaction.descriptor.name.should == "123*123456789012345678"
+ result.transaction.descriptor.phone.should == "3334445555"
+ result.transaction.descriptor.url.should == "ebay.com"
end
it "has validation errors if format is invalid" do
result = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:descriptor => {
- :name => 'badcompanyname12*badproduct12',
- :phone => '%bad4445555',
- :url => '12345678901234'
- }
+ :name => "badcompanyname12*badproduct12",
+ :phone => "%bad4445555",
+ :url => "12345678901234"
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:phone)[0].code.should == Braintree::ErrorCodes::Descriptor::PhoneFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:url)[0].code.should == Braintree::ErrorCodes::Descriptor::UrlFormatIsInvalid
@@ -1339,29 +1339,29 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :tax_amount => '0.05',
+ :tax_amount => "0.05",
:tax_exempt => false,
- :purchase_order_number => '12345678901234567'
+ :purchase_order_number => "12345678901234567",
)
result.success?.should == true
result.transaction.tax_amount.should == BigDecimal("0.05")
result.transaction.tax_exempt.should == false
- result.transaction.purchase_order_number.should == '12345678901234567'
+ result.transaction.purchase_order_number.should == "12345678901234567"
end
it "accepts tax_amount as a BigDecimal" do
result = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :tax_amount => BigDecimal('1.99'),
- :tax_exempt => true
+ :tax_amount => BigDecimal("1.99"),
+ :tax_exempt => true,
)
result.success?.should == true
result.transaction.tax_amount.should == BigDecimal("1.99")
result.transaction.tax_exempt.should == true
result.transaction.purchase_order_number.should be_nil
@@ -1373,11 +1373,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :tax_amount => 'abcd'
+ :tax_amount => "abcd",
)
result.success?.should == false
result.errors.for(:transaction).on(:tax_amount)[0].code.should == Braintree::ErrorCodes::Transaction::TaxAmountFormatIsInvalid
end
@@ -1386,11 +1386,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :purchase_order_number => 'a' * 18
+ :purchase_order_number => "a" * 18,
)
result.success?.should == false
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsTooLong
end
@@ -1399,11 +1399,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :purchase_order_number => "\303\237\303\245\342\210\202"
+ :purchase_order_number => "\303\237\303\245\342\210\202",
)
result.success?.should == false
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsInvalid
end
end
@@ -1416,11 +1416,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :transaction_source => "recurring_first"
+ :transaction_source => "recurring_first",
)
result.success?.should == true
result.transaction.recurring.should == true
end
@@ -1430,11 +1430,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :transaction_source => "recurring"
+ :transaction_source => "recurring",
)
result.success?.should == true
result.transaction.recurring.should == true
end
@@ -1444,11 +1444,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :transaction_source => "merchant"
+ :transaction_source => "merchant",
)
result.success?.should == true
result.transaction.recurring.should == false
end
@@ -1458,11 +1458,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :transaction_source => "moto"
+ :transaction_source => "moto",
)
result.success?.should == true
result.transaction.recurring.should == false
end
@@ -1472,11 +1472,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :transaction_source => "invalid_value"
+ :transaction_source => "invalid_value",
)
result.success?.should == false
result.errors.for(:transaction).on(:transaction_source)[0].code.should == Braintree::ErrorCodes::Transaction::TransactionSourceIsInvalid
end
end
@@ -1492,11 +1492,11 @@
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :options => { :store_in_vault_on_success => true }
+ :options => {:store_in_vault_on_success => true},
)
result.success?.should == true
result.transaction.vault_customer.last_name.should == "Doe"
result.transaction.vault_credit_card.masked_number.should == "401288******1881"
result.transaction.credit_card_details.unique_number_identifier.should_not be_nil
@@ -1511,11 +1511,11 @@
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :options => { :store_in_vault_on_success => true }
+ :options => {:store_in_vault_on_success => true},
)
result.success?.should == false
result.transaction.vault_customer.should be_nil
result.transaction.vault_credit_card.should be_nil
end
@@ -1531,11 +1531,11 @@
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :options => { :store_in_vault_on_success => false }
+ :options => {:store_in_vault_on_success => false},
)
result.success?.should == true
result.transaction.vault_customer.should be_nil
result.transaction.vault_credit_card.should be_nil
end
@@ -1549,11 +1549,11 @@
},
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :options => { :store_in_vault_on_success => false }
+ :options => {:store_in_vault_on_success => false},
)
result.success?.should == false
result.transaction.vault_customer.should be_nil
result.transaction.vault_credit_card.should be_nil
end
@@ -1568,11 +1568,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :service_fee_amount => "1.00"
+ :service_fee_amount => "1.00",
)
result.success?.should == true
result.transaction.service_fee_amount.should == BigDecimal("1.00")
end
@@ -1583,11 +1583,11 @@
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :service_fee_amount => "1.00"
+ :service_fee_amount => "1.00",
)
result.success?.should == false
expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == expected_error_code
end
@@ -1598,30 +1598,30 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
- }
+ },
)
result.success?.should == false
expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
result.errors.for(:transaction).on(:merchant_account_id)[0].code.should == expected_error_code
end
it "raises an error if service fee amount is negative" do
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
- :service_fee_amount => "-1.00"
+ :service_fee_amount => "-1.00",
)
result.success?.should == false
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative
end
it "raises an error if service fee amount is invalid" do
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
- :service_fee_amount => "invalid amount"
+ :service_fee_amount => "invalid amount",
)
result.success?.should == false
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid
end
end
@@ -1635,11 +1635,11 @@
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
:service_fee_amount => "10.00",
- :options => {:hold_in_escrow => true}
+ :options => {:hold_in_escrow => true},
)
result.success?.should == true
result.transaction.escrow_status.should == Braintree::Transaction::EscrowStatus::HoldPending
end
@@ -1652,11 +1652,11 @@
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
:service_fee_amount => "1.00",
- :options => {:hold_in_escrow => true}
+ :options => {:hold_in_escrow => true},
)
result.success?.should == false
expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
result.errors.for(:transaction).on(:base)[0].code.should == expected_error_code
end
@@ -1665,11 +1665,11 @@
describe "venmo_sdk" do
it "can create a card with a venmo sdk payment method code" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
+ :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
)
result.success?.should == true
result.transaction.credit_card_details.bin.should == "400934"
result.transaction.credit_card_details.last_4.should == "1881"
end
@@ -1682,11 +1682,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
:options => {
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.venmo_sdk?.should == false
end
end
@@ -1697,18 +1697,18 @@
:credit_card => {
:number => "4111111111111111",
:expiration_month => "11",
:expiration_year => "2099",
},
- :share => true
+ :share => true,
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.success?.should == true
end
it "can create a transaction with a vaulted card nonce" do
@@ -1719,18 +1719,18 @@
:expiration_month => "11",
:expiration_year => "2099",
},
:client_token_options => {
:customer_id => customer.id,
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.success?.should == true
end
it "can create a transaction with a vaulted PayPal account" do
@@ -1739,18 +1739,18 @@
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
},
:client_token_options => {
:customer_id => customer.id,
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
end
@@ -1758,18 +1758,18 @@
it "can create a transaction with a params nonce with PayPal account params" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
end
@@ -1777,11 +1777,11 @@
it "can create a transaction with a fake apple pay nonce" do
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
)
result.success?.should == true
result.transaction.should_not be_nil
apple_pay_details = result.transaction.apple_pay_details
apple_pay_details.should_not be_nil
@@ -1807,11 +1807,11 @@
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
- :options => { :store_in_vault_on_success => true }
+ :options => {:store_in_vault_on_success => true},
)
result.success?.should == true
result.transaction.should_not be_nil
apple_pay_details = result.transaction.apple_pay_details
apple_pay_details.should_not be_nil
@@ -1828,11 +1828,11 @@
it "can create a transaction with a fake google pay proxy card nonce" do
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
)
result.success?.should == true
result.transaction.should_not be_nil
google_pay_details = result.transaction.google_pay_details
google_pay_details.should_not be_nil
@@ -1861,11 +1861,11 @@
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
- :options => { :store_in_vault_on_success => true }
+ :options => {:store_in_vault_on_success => true},
)
result.success?.should == true
result.transaction.should_not be_nil
google_pay_details = result.transaction.google_pay_details
google_pay_details.should_not be_nil
@@ -1885,11 +1885,11 @@
it "can create a transaction with a fake google pay network token nonce" do
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
)
result.success?.should == true
result.transaction.should_not be_nil
google_pay_details = result.transaction.google_pay_details
google_pay_details.should_not be_nil
@@ -1908,11 +1908,11 @@
result = Braintree::Transaction.create(
:type => "sale",
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
- :options => {:store_in_vault => true}
+ :options => {:store_in_vault => true},
)
result.should be_success
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::VenmoAccount
venmo_account_details = result.transaction.venmo_account_details
@@ -1928,21 +1928,21 @@
result = Braintree::Transaction.create(
:type => "sale",
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
- :options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id" }}
+ :options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id"}},
)
result.should be_success
end
it "can create a transaction with an unknown nonce" do
customer = Braintree::Customer.create!
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable
+ :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
)
result.success?.should == true
result.transaction.should_not be_nil
end
@@ -1953,11 +1953,11 @@
:submit_for_settlement => true
},
:paypal_account => {
:payer_id => "PAYER-1234",
:payment_id => "PAY-5678",
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::Settling
result.transaction.paypal_details.payer_id.should == "PAYER-1234"
@@ -1967,21 +1967,21 @@
it "can create a transaction with a payee id" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
:paypal_account => {
:payee_id => "fake-payee-id"
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -1991,22 +1991,22 @@
it "can create a transaction with a payee id in the options params" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
:paypal_account => {},
:options => {
:payee_id => "fake-payee-id"
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2016,11 +2016,11 @@
it "can create a transaction with a payee id in options.paypal" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
@@ -2028,11 +2028,11 @@
:payment_method_nonce => nonce,
:options => {
:paypal => {
:payee_id => "fake-payee-id"
}
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2042,21 +2042,21 @@
it "can create a transaction with a payee email" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
:paypal_account => {
:payee_email => "bt_seller_us@paypal.com"
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2066,22 +2066,22 @@
it "can create a transaction with a payee email in the options params" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
:paypal_account => {},
:options => {
:payee_email => "bt_seller_us@paypal.com"
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2091,11 +2091,11 @@
it "can create a transaction with a payee email in options.paypal" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
@@ -2103,11 +2103,11 @@
:payment_method_nonce => nonce,
:options => {
:paypal => {
:payee_email => "bt_seller_us@paypal.com"
}
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2117,11 +2117,11 @@
it "can create a transaction with a paypal custom field" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
@@ -2129,11 +2129,11 @@
:payment_method_nonce => nonce,
:options => {
:paypal => {
:custom_field => "Additional info"
}
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2143,11 +2143,11 @@
it "can create a transaction with a paypal description" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
@@ -2155,11 +2155,11 @@
:payment_method_nonce => nonce,
:options => {
:paypal => {
:description => "A great product"
}
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2169,11 +2169,11 @@
it "can create a transaction with STC supplementary data" do
customer = Braintree::Customer.create!
nonce = nonce_for_new_payment_method(
:paypal_account => {
:consent_code => "PAYPAL_CONSENT_CODE",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:type => "sale",
@@ -2184,11 +2184,11 @@
:supplementary_data => {
:key1 => "value1",
:key2 => "value2",
}
}
- }
+ },
)
# note - supplementary data is not returned in response
result.success?.should == true
end
@@ -2198,22 +2198,22 @@
it "can create a transaction with a three_d_secure token" do
three_d_secure_token = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:type => "sale",
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :three_d_secure_token => three_d_secure_token
+ :three_d_secure_token => three_d_secure_token,
)
result.success?.should == true
end
@@ -2221,11 +2221,11 @@
nonce = nonce_for_new_payment_method(
:credit_card => {
:number => "4111111111111111",
:expiration_month => "11",
:expiration_year => "2099",
- }
+ },
)
nonce.should_not be_nil
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
@@ -2233,11 +2233,11 @@
:payment_method_nonce => nonce,
:options => {
:three_d_secure => {
:required => true,
}
- }
+ },
)
result.success?.should == false
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ThreeDSecure
end
@@ -2249,33 +2249,33 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
- }
+ },
)
result.success?.should == true
end
context "with three_d_secure_authentication_id" do
it "can create a transaction with a three_d_secure_authentication_id" do
three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2022"
+ :expiration_year => "2022",
)
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/22",
},
- :three_d_secure_authentication_id => three_d_secure_authentication_id
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
)
result.success?.should == true
end
it "returns an error if sent a nil three_d_secure_authentication_id" do
@@ -2285,62 +2285,62 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :three_d_secure_authentication_id => nil
+ :three_d_secure_authentication_id => nil,
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdIsInvalid
end
it "returns an error if merchant_account in the payment_method does not match with 3ds data" do
three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::MasterCard,
:expiration_date => "12/12",
},
- :three_d_secure_authentication_id => three_d_secure_authentication_id
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
end
it "returns an error if 3ds lookup data does not match txn data" do
three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::MasterCard,
:expiration_date => "12/12",
},
- :three_d_secure_authentication_id => three_d_secure_authentication_id
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
end
it "returns an error if three_d_secure_authentication_id is supplied with three_d_secure_pass_thru" do
three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -2356,11 +2356,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdWithThreeDSecurePassThruIsInvalid
end
end
@@ -2369,22 +2369,22 @@
it "can create a transaction with a three_d_secure token" do
three_d_secure_token = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :three_d_secure_token => three_d_secure_token
+ :three_d_secure_token => three_d_secure_token,
)
result.success?.should == true
end
@@ -2395,33 +2395,33 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :three_d_secure_token => nil
+ :three_d_secure_token => nil,
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTokenIsInvalid
end
it "returns an error if 3ds lookup data does not match txn data" do
three_d_secure_token = SpecHelper.create_3ds_verification(
SpecHelper::ThreeDSecureMerchantAccountId,
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "12",
- :expiration_year => "2012"
+ :expiration_year => "2012",
)
result = Braintree::Transaction.create(
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::MasterCard,
:expiration_date => "12/12",
},
- :three_d_secure_token => three_d_secure_token
+ :three_d_secure_token => three_d_secure_token,
)
result.success?.should == false
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionDataDoesntMatchVerify
end
end
@@ -2441,11 +2441,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::Authorized
end
@@ -2466,11 +2466,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).on(:merchant_account_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureMerchantAccountDoesNotSupportCardType
end
@@ -2484,11 +2484,11 @@
},
:three_d_secure_pass_thru => {
:eci_flag => "",
:cavv => "some_cavv",
:xid => "some_xid",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsRequired
end
@@ -2507,11 +2507,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvIsRequired
end
@@ -2530,11 +2530,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsInvalid
end
@@ -2553,11 +2553,11 @@
:three_d_secure_version => "invalid",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid
end
@@ -2577,11 +2577,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "asdf",
:directory_response => "Y",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid
end
@@ -2601,11 +2601,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "abc",
:cavv_algorithm => "2",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:directory_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureDirectoryResponseIsInvalid
end
@@ -2625,11 +2625,11 @@
:three_d_secure_version => "1.0.2",
:authentication_response => "Y",
:directory_response => "Y",
:cavv_algorithm => "bad_alg",
:ds_transaction_id => "some_ds_id",
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv_algorithm)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvAlgorithmIsInvalid
end
end
@@ -2637,16 +2637,16 @@
context "paypal" do
context "using a vaulted paypal account payment_method_token" do
it "can create a transaction" do
payment_method_result = Braintree::PaymentMethod.create(
:customer_id => Braintree::Customer.create.customer.id,
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_token => payment_method_result.payment_method.token
+ :payment_method_token => payment_method_result.payment_method.token,
)
result.should be_success
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::PayPalAccount
result.transaction.paypal_details.should_not be_nil
@@ -2657,17 +2657,17 @@
context "future" do
it "can create a paypal transaction with a nonce without vaulting" do
payment_method_token = rand(36**3).to_s(36)
nonce = nonce_for_paypal_account(
:consent_code => "PAYPAL_CONSENT_CODE",
- :token => payment_method_token
+ :token => payment_method_token,
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.should be_success
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2679,18 +2679,18 @@
it "can create a paypal transaction and vault a paypal account" do
payment_method_token = rand(36**3).to_s(36)
nonce = nonce_for_paypal_account(
:consent_code => "PAYPAL_CONSENT_CODE",
- :token => payment_method_token
+ :token => payment_method_token,
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
- :options => {:store_in_vault => true}
+ :options => {:store_in_vault => true},
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2705,11 +2705,11 @@
it "can create a paypal billing agreement" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
- :options => {:store_in_vault => true}
+ :options => {:store_in_vault => true},
)
result.should be_success
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2720,11 +2720,11 @@
context "local payments" do
it "can create a local payment transaction with a nonce" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::LocalPayment
+ :payment_method_nonce => Braintree::Test::Nonce::LocalPayment,
)
result.should be_success
result.transaction.local_payment_details.should_not be_nil
result.transaction.local_payment_details.funding_source.should_not be_nil
@@ -2738,11 +2738,11 @@
context "onetime" do
it "can create a paypal transaction with a nonce" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
)
result.should be_success
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2750,18 +2750,18 @@
it "can create a paypal transaction and does not vault even if asked to" do
payment_method_token = rand(36**3).to_s(36)
nonce = nonce_for_paypal_account(
:access_token => "PAYPAL_ACCESS_TOKEN",
- :token => payment_method_token
+ :token => payment_method_token,
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => nonce,
- :options => {:store_in_vault => true}
+ :options => {:store_in_vault => true},
)
result.success?.should == true
result.transaction.paypal_details.should_not be_nil
result.transaction.paypal_details.debug_id.should_not be_nil
@@ -2777,33 +2777,33 @@
result = Braintree::Transaction.sale(
:amount => "100",
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
:options => {
:submit_for_settlement => true
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::Settling
end
end
context "void" do
it "successfully voids a paypal transaction that's been authorized" do
sale_transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
)
void_transaction = Braintree::Transaction.void!(sale_transaction.id)
void_transaction.should == sale_transaction
void_transaction.status.should == Braintree::Transaction::Status::Voided
end
it "fails to void a paypal transaction that's been declined" do
sale_transaction = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Decline,
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
).transaction
expect do
Braintree::Transaction.void!(sale_transaction.id)
end.to raise_error(Braintree::ValidationsFailed)
@@ -2869,10 +2869,23 @@
result.transaction.type.should == "credit"
result.transaction.order_id.should == "123458798123"
result.transaction.amount.should == transaction.amount/2
end
+ it "allows merchant_account_id to be passed for the refund" do
+ transaction = create_transaction_to_refund
+
+ result = Braintree::Transaction.refund(
+ transaction.id,
+ :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
+ )
+
+ result.success?.should == true
+ result.transaction.type.should == "credit"
+ result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
+ end
+
it "does not allow arbitrary options to be passed" do
transaction = create_paypal_transaction_for_refund
expect {
Braintree::Transaction.refund(transaction.id, :blah => "123458798123")
@@ -2887,11 +2900,11 @@
end
it "returns an error result if unsettled" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
)
result = Braintree::Transaction.refund(transaction.id)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotRefundUnlessSettled
end
@@ -2900,11 +2913,11 @@
transaction = Braintree::Transaction.sale!(
:amount => "9000.00",
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
:options => {
:submit_for_settlement => true
- }
+ },
)
config = Braintree::Configuration.instantiate
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
result = Braintree::Transaction.refund(transaction.id, :amount => "2046.00")
result.success?.should == false
@@ -2921,11 +2934,11 @@
transaction = Braintree::Transaction.sale!(
:amount => "9000.00",
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
:options => {
:submit_for_settlement => true
- }
+ },
)
config = Braintree::Configuration.instantiate
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
result = Braintree::Transaction.refund(transaction.id, :amount => "2009.00")
result.success?.should == false
@@ -2941,28 +2954,28 @@
context "handling errors" do
it "handles bad unvalidated nonces" do
nonce = nonce_for_paypal_account(
:access_token => "PAYPAL_ACCESS_TOKEN",
- :consent_code => "PAYPAL_CONSENT_CODE"
+ :consent_code => "PAYPAL_CONSENT_CODE",
)
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.should_not be_success
result.errors.for(:transaction).for(:paypal_account).first.code.should == "82903"
end
it "handles non-existent nonces" do
result = Braintree::Transaction.create(
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
- :payment_method_nonce => "NON_EXISTENT_NONCE"
+ :payment_method_nonce => "NON_EXISTENT_NONCE",
)
result.should_not be_success
result.errors.for(:transaction).first.code.should == "91565"
end
@@ -4086,11 +4099,11 @@
:kind => "credit",
:unit_amount => "5",
:unit_of_measure => "gallon",
:total_amount => "10.1",
},
- ['Name #2'],
+ ["Name #2"],
{
:quantity => "2.02",
:name => "Name #3",
:kind => "credit",
:unit_amount => "5",
@@ -4272,11 +4285,11 @@
context "external vault" do
it "returns a validation error if used with an unsupported instrument type" do
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
- :customer_id => customer.id
+ :customer_id => customer.id,
)
payment_method_token = result.payment_method.token
result = Braintree::Transaction.create(
:type => "sale",
@@ -4407,11 +4420,11 @@
:amount => "10.00",
:options => {
:credit_card => {
:account_type => "credit",
}
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.account_type.should == "credit"
end
@@ -4426,11 +4439,11 @@
:amount => "10.00",
:options => {
:credit_card => {
:account_type => "credit",
}
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.account_type.should == "credit"
end
@@ -4446,11 +4459,11 @@
:options => {
:credit_card => {
:account_type => "debit",
},
:submit_for_settlement => true,
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.account_type.should == "debit"
end
@@ -4465,11 +4478,11 @@
:amount => "10.00",
:options => {
:credit_card => {
:account_type => "debit",
},
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeDebitDoesNotSupportAuths
end
@@ -4484,11 +4497,11 @@
:amount => "10.00",
:options => {
:credit_card => {
:account_type => "ach",
},
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeIsInvalid
end
@@ -4502,11 +4515,11 @@
:amount => "10.00",
:options => {
:credit_card => {
:account_type => "credit",
},
- }
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeNotSupported
end
end
@@ -4518,11 +4531,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
transaction.id.should =~ /^\w{6,}$/
transaction.type.should == "sale"
transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
@@ -4536,11 +4549,11 @@
:type => "sale",
:amount => nil,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
end.to raise_error(Braintree::ValidationsFailed)
end
end
@@ -4592,11 +4605,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.refund(transaction.id)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotRefundUnlessSettled
end
@@ -4629,11 +4642,11 @@
result = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "sale"
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
@@ -4685,11 +4698,11 @@
:region => "IL",
:phone_number => "122-555-1236",
:postal_code => "60103",
:country_name => "United States of America",
:shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.id.should =~ /\A\w{6,}\z/
transaction.type.should == "sale"
@@ -4749,11 +4762,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
end
@@ -4761,11 +4774,11 @@
result = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
end
@@ -4780,11 +4793,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:options => {
:store_in_vault => true
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.customer_details.id.should =~ /\A\d{6,}\z/
transaction.vault_customer.id.should == transaction.customer_details.id
@@ -4815,11 +4828,11 @@
:country_name => "United States of America"
},
:options => {
:store_in_vault => true,
:add_billing_address_to_payment_method => true,
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.customer_details.id.should =~ /\A\d{6,}\z/
transaction.vault_customer.id.should == transaction.customer_details.id
@@ -4860,11 +4873,11 @@
:country_name => "United States of America"
},
:options => {
:store_in_vault => true,
:store_shipping_address_in_vault => true,
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.customer_details.id.should =~ /\A\d{6,}\z/
transaction.vault_customer.id.should == transaction.customer_details.id
@@ -4886,11 +4899,11 @@
:amount => "100",
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/2012"
},
- :options => { :store_in_vault => true }
+ :options => {:store_in_vault => true},
)
result.success?.should == true
transaction = result.transaction
@@ -4904,11 +4917,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:options => {
:submit_for_settlement => true
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
@@ -4927,11 +4940,11 @@
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:options => {
:store_in_vault => true
- }
+ },
)
result.success?.should == true
transaction = result.transaction
transaction.customer_details.id.should == customer_id
transaction.vault_customer.id.should == customer_id
@@ -4942,24 +4955,24 @@
it "can specify existing shipping address" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
address = Braintree::Address.create!(
:customer_id => customer.id,
- :street_address => '123 Fake St.'
+ :street_address => "123 Fake St.",
)
result = Braintree::Transaction.sale(
:amount => "100",
:customer_id => customer.id,
- :shipping_address_id => address.id
+ :shipping_address_id => address.id,
)
result.success?.should == true
transaction = result.transaction
- transaction.shipping_details.street_address.should == '123 Fake St.'
+ transaction.shipping_details.street_address.should == "123 Fake St."
transaction.customer_details.id.should == customer.id
transaction.shipping_details.id.should == address.id
end
it "returns an error result if validations fail" do
@@ -4972,11 +4985,11 @@
}
}
}
result = Braintree::Transaction.sale(params[:transaction])
result.success?.should == false
- result.params.should == {:transaction => {:type => 'sale', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
+ result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
end
it "validates currency_iso_code and creates transaction" do
params = {
@@ -5053,11 +5066,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:skip_advanced_fraud_checking => true
- }
+ },
)
result.success?.should == true
result.transaction.risk_data.should be_nil
end
end
@@ -5147,11 +5160,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
@@ -5169,11 +5182,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
@@ -5191,11 +5204,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
end
@@ -5214,11 +5227,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
result.success?.should == true
@@ -5238,11 +5251,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::Authorized
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
@@ -5263,11 +5276,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::Authorized
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
@@ -5283,11 +5296,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
transaction.id.should =~ /^\w{6,}$/
transaction.type.should == "sale"
transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
@@ -5300,11 +5313,11 @@
Braintree::Transaction.sale!(
:amount => nil,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
end.to raise_error(Braintree::ValidationsFailed)
end
end
@@ -5313,11 +5326,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_settlement(transaction.id)
result.success?.should == true
end
@@ -5325,11 +5338,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
transaction.amount.should == BigDecimal("1000.00")
result = Braintree::Transaction.submit_for_settlement(transaction.id, "999.99")
result.success?.should == true
result.transaction.amount.should == BigDecimal("999.99")
@@ -5341,13 +5354,13 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
- options = { :order_id => "ABC123" }
+ options = {:order_id => "ABC123"}
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
result.success?.should == true
result.transaction.order_id.should == "ABC123"
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
@@ -5356,52 +5369,53 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
options = {
:descriptor => {
- :name => '123*123456789012345678',
- :phone => '3334445555',
+ :name => "123*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com"
}
}
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
- result.transaction.descriptor.name.should == '123*123456789012345678'
- result.transaction.descriptor.phone.should == '3334445555'
- result.transaction.descriptor.url.should == 'ebay.com'
+ result.transaction.descriptor.name.should == "123*123456789012345678"
+ result.transaction.descriptor.phone.should == "3334445555"
+ result.transaction.descriptor.url.should == "ebay.com"
end
it "raises an error if an invalid option is passed in" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
- options = { :order_id => "ABC123", :invalid_option => "i'm invalid" }
+ options = {:order_id => "ABC123", :invalid_option => "i'm invalid"}
expect do
Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
end.to raise_error(ArgumentError)
end
it "returns an error result if settlement is too large" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
+ :merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
transaction.amount.should == BigDecimal("1000.00")
result = Braintree::Transaction.submit_for_settlement(transaction.id, "1000.01")
result.success?.should == false
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
@@ -5412,11 +5426,11 @@
transaction = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Decline,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
).transaction
result = Braintree::Transaction.submit_for_settlement(transaction.id)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement
end
@@ -5429,11 +5443,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
},
- :service_fee_amount => "1.00"
+ :service_fee_amount => "1.00",
).transaction
result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
result.success?.should == false
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsLessThanServiceFeeAmount
end
@@ -5452,11 +5466,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result = Braintree::Transaction.submit_for_settlement(result.transaction.id, nil, :tax_amount => "2.00", :tax_exempt => false, :purchase_order_number => "0Rd3r#")
result.success?.should == true
@@ -5476,11 +5490,11 @@
:request_id => "ABC123",
:points => "1000",
:currency_amount => "10.00",
:currency_iso_code => "USD"
}
- }
+ },
)
result.success?.should == true
result = Braintree::Transaction.submit_for_settlement(
result.transaction.id,
@@ -5496,11 +5510,11 @@
:kind => "debit",
:total_amount => "18.00",
:discount_amount => "12.00",
:tax_amount => "0",
},
- ]
+ ],
)
result.success?.should == true
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
end
@@ -5510,26 +5524,27 @@
original_transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
- options = { :order_id => "ABC123" }
+ options = {:order_id => "ABC123"}
transaction = Braintree::Transaction.submit_for_settlement!(original_transaction.id, "0.01", options)
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
transaction.id.should == original_transaction.id
transaction.order_id.should == options[:order_id]
end
it "raises a ValidationsFailed if unsuccessful" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
+ :merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
transaction.amount.should == BigDecimal("1000.00")
expect do
Braintree::Transaction.submit_for_settlement!(transaction.id, "1000.01")
end.to raise_error(Braintree::ValidationsFailed)
@@ -5541,79 +5556,79 @@
let(:transaction) do
Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:descriptor => {
- :name => '123*123456789012345678',
- :phone => '3334445555',
+ :name => "123*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com"
},
- :order_id => '123',
+ :order_id => "123",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
},
:options => {
:submit_for_settlement => true
- }
+ },
)
end
it "successfully updates details" do
result = Braintree::Transaction.update_details(transaction.id, {
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => '456'
+ :order_id => "456"
})
result.success?.should == true
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize) - 1
- result.transaction.order_id.should == '456'
- result.transaction.descriptor.name.should == '456*123456789012345678'
+ result.transaction.order_id.should == "456"
+ result.transaction.descriptor.name.should == "456*123456789012345678"
end
it "raises an error when a key is invalid" do
expect do
Braintree::Transaction.update_details(transaction.id, {
:invalid_key => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => '456'
+ :order_id => "456"
})
end.to raise_error(ArgumentError)
end
describe "errors" do
it "returns an error response when the settlement amount is invalid" do
result = Braintree::Transaction.update_details(transaction.id, {
:amount => "10000",
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => '456'
+ :order_id => "456"
})
result.success?.should == false
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
end
it "returns an error response when the descriptor is invalid" do
result = Braintree::Transaction.update_details(transaction.id, {
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => 'invalid descriptor name',
- :phone => 'invalid phone',
- :url => '12345678901234'
+ :name => "invalid descriptor name",
+ :phone => "invalid phone",
+ :url => "12345678901234"
},
- :order_id => '456'
+ :order_id => "456"
})
result.success?.should == false
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:phone)[0].code.should == Braintree::ErrorCodes::Descriptor::PhoneFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:url)[0].code.should == Braintree::ErrorCodes::Descriptor::UrlFormatIsInvalid
@@ -5621,46 +5636,46 @@
it "returns an error response when the order_id is invalid" do
result = Braintree::Transaction.update_details(transaction.id, {
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => 'x' * 256
+ :order_id => "x" * 256
})
result.success?.should == false
result.errors.for(:transaction).on(:order_id)[0].code.should == Braintree::ErrorCodes::Transaction::OrderIdIsTooLong
end
it "returns an error on an unsupported processor" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
:descriptor => {
- :name => '123*123456789012345678',
- :phone => '3334445555',
+ :name => "123*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com"
},
- :order_id => '123',
+ :order_id => "123",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
:expiration_date => "05/2009"
},
:options => {
:submit_for_settlement => true
- }
+ },
)
result = Braintree::Transaction.update_details(transaction.id, {
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => '456'
+ :order_id => "456"
})
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportUpdatingTransactionDetails
end
end
@@ -5670,28 +5685,28 @@
it "returns an error" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:descriptor => {
- :name => '123*123456789012345678',
- :phone => '3334445555',
+ :name => "123*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com"
},
- :order_id => '123',
+ :order_id => "123",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
result = Braintree::Transaction.update_details(transaction.id, {
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
:descriptor => {
- :name => '456*123456789012345678',
- :phone => '3334445555',
+ :name => "456*123456789012345678",
+ :phone => "3334445555",
:url => "ebay.com",
},
- :order_id => '456'
+ :order_id => "456"
})
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotUpdateTransactionDetailsNotSubmittedForSettlement
end
end
@@ -5704,11 +5719,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
result.success?.should == true
partial_settlement_transaction1 = result.transaction
@@ -5739,11 +5754,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => 1234)
result.success?.should == true
partial_settlement_transaction = result.transaction
@@ -5755,11 +5770,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => "1"*256)
result.success?.should == false
result.errors.for(:transaction).on(:order_id)[0].code.should == Braintree::ErrorCodes::Transaction::OrderIdIsTooLong
@@ -5770,17 +5785,17 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(
authorized_transaction.id,
100,
- :descriptor => { :name => "123*123456789012345678", :phone => "5555551234", :url => "url.com" }
+ :descriptor => {:name => "123*123456789012345678", :phone => "5555551234", :url => "url.com"},
)
result.success?.should == true
partial_settlement_transaction = result.transaction
partial_settlement_transaction.descriptor.name.should == "123*123456789012345678"
partial_settlement_transaction.descriptor.phone.should == "5555551234"
@@ -5792,21 +5807,21 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(
authorized_transaction.id,
100,
:descriptor => {
:name => "invalid_format",
- :phone => '%bad4445555',
- :url => '12345678901234'
- }
+ :phone => "%bad4445555",
+ :url => "12345678901234"
+ },
)
result.success?.should == false
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:phone)[0].code.should == Braintree::ErrorCodes::Descriptor::PhoneFormatIsInvalid
result.errors.for(:transaction).for(:descriptor).on(:url)[0].code.should == Braintree::ErrorCodes::Descriptor::UrlFormatIsInvalid
@@ -5817,11 +5832,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialSettlement
@@ -5829,11 +5844,11 @@
it "returns an error with an invalid payment instrument type" do
authorized_transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
- :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
+ :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentInstrumentTypeIsNotAccepted
@@ -5844,11 +5859,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
result.success?.should == true
@@ -5862,11 +5877,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
result = Braintree::Transaction.void(authorized_transaction.id)
result.success?.should == true
@@ -5881,13 +5896,13 @@
original_transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
- options = { :order_id => "ABC123" }
+ options = {:order_id => "ABC123"}
transaction = Braintree::Transaction.submit_for_partial_settlement!(original_transaction.id, "0.01", options)
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
transaction.order_id.should == options[:order_id]
end
@@ -5895,11 +5910,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "06/2009"
- }
+ },
)
transaction.amount.should == BigDecimal("1000.00")
expect do
Braintree::Transaction.submit_for_partial_settlement!(transaction.id, "1000.01")
end.to raise_error(Braintree::ValidationsFailed)
@@ -5920,11 +5935,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :service_fee_amount => '1.00'
+ :service_fee_amount => "1.00",
)
transaction.escrow_status.should be_nil
result = Braintree::Transaction.release_from_escrow(transaction.id)
@@ -5946,11 +5961,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :service_fee_amount => '1.00'
+ :service_fee_amount => "1.00",
)
transaction.escrow_status.should be_nil
expect do
@@ -6006,11 +6021,11 @@
result = Braintree::Transaction.credit(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.id.should =~ /^\w{6,}$/
result.transaction.type.should == "credit"
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
@@ -6029,22 +6044,22 @@
}
}
}
result = Braintree::Transaction.credit(params[:transaction])
result.success?.should == false
- result.params.should == {:transaction => {:type => 'credit', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
+ result.params.should == {:transaction => {:type => "credit", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
end
it "allows merchant account to be specified" do
result = Braintree::Transaction.credit(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
end
@@ -6052,11 +6067,11 @@
result = Braintree::Transaction.credit(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
end
@@ -6082,11 +6097,11 @@
transaction = Braintree::Transaction.credit!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
transaction.id.should =~ /^\w{6,}$/
transaction.type.should == "credit"
transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize)
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
@@ -6099,11 +6114,11 @@
Braintree::Transaction.credit!(
:amount => nil,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
end.to raise_error(Braintree::ValidationsFailed)
end
end
@@ -6113,11 +6128,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
created_transaction = result.transaction
found_transaction = Braintree::Transaction.find(created_transaction.id)
found_transaction.should == created_transaction
@@ -6130,11 +6145,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :options => { :store_in_vault => true }
+ :options => {:store_in_vault => true},
)
result.success?.should == true
created_transaction = result.transaction
found_transaction = Braintree::Transaction.find(created_transaction.id)
found_transaction.should == created_transaction
@@ -6175,11 +6190,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
created_transaction = result.transaction
created_transaction.disbursed?.should == false
@@ -6225,11 +6240,11 @@
:type => "sale",
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result.success?.should == true
created_transaction = result.transaction
created_transaction.disputes.should == []
@@ -6294,11 +6309,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :service_fee_amount => "10.00"
+ :service_fee_amount => "10.00",
)
result.transaction.escrow_status.should be_nil
result = Braintree::Transaction.hold_in_escrow(result.transaction.id)
@@ -6311,11 +6326,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.hold_in_escrow(transaction.id)
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
end
@@ -6329,11 +6344,11 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "12/12",
},
- :service_fee_amount => "10.00"
+ :service_fee_amount => "10.00",
)
result.transaction.escrow_status.should be_nil
transaction = Braintree::Transaction.hold_in_escrow!(result.transaction.id)
@@ -6345,11 +6360,11 @@
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
expect do
Braintree::Transaction.hold_in_escrow!(transaction.id)
end.to raise_error(Braintree::ValidationsFailed)
@@ -6361,11 +6376,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.void(transaction.id)
result.success?.should == true
result.transaction.id.should == transaction.id
result.transaction.status.should == Braintree::Transaction::Status::Voided
@@ -6375,11 +6390,11 @@
transaction = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Decline,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
).transaction
result = Braintree::Transaction.void(transaction.id)
result.success?.should == false
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotBeVoided
end
@@ -6390,11 +6405,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
returned_transaction = Braintree::Transaction.void!(transaction.id)
returned_transaction.should == transaction
returned_transaction.status.should == Braintree::Transaction::Status::Voided
end
@@ -6403,11 +6418,11 @@
transaction = Braintree::Transaction.sale(
:amount => Braintree::Test::TransactionAmounts::Decline,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
).transaction
expect do
Braintree::Transaction.void!(transaction.id)
end.to raise_error(Braintree::ValidationsFailed)
end
@@ -6418,11 +6433,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
- }
+ },
)
result = Braintree::Transaction.submit_for_settlement!(transaction.id)
result.status_history.size.should == 2
result.status_history[0].status.should == Braintree::Transaction::Status::Authorized
result.status_history[1].status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -6476,11 +6491,11 @@
it "returns the Braintree::CreditCard if the transaction credit card is stored in the vault" 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
transaction.vault_credit_card.should == customer.credit_cards[0]
end
@@ -6489,11 +6504,11 @@
:amount => "100.00",
:type => "sale",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
transaction.vault_credit_card.should == nil
end
end
@@ -6501,11 +6516,11 @@
it "returns the Braintree::Customer if the transaction customer is stored in the vault" 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
transaction.vault_customer.should == customer
end
@@ -6514,11 +6529,11 @@
:amount => "100.00",
:type => "sale",
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2010"
- }
+ },
)
transaction.vault_customer.should == nil
end
end
@@ -6529,11 +6544,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:submit_for_settlement => true
- }
+ },
)
config = Braintree::Configuration.instantiate
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
Braintree::Transaction.find(transaction.id)
@@ -6543,11 +6558,11 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
:options => {
:submit_for_settlement => true
- }
+ },
)
config = Braintree::Configuration.instantiate
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
Braintree::Transaction.find(transaction.id)
@@ -6559,12 +6574,12 @@
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
- :service_fee_amount => '1.00',
- :options => { :hold_in_escrow => true }
+ :service_fee_amount => "1.00",
+ :options => {:hold_in_escrow => true},
)
config = Braintree::Configuration.instantiate
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/escrow")
@@ -6574,20 +6589,20 @@
context "venmo sdk" do
describe "venmo_sdk_payment_method_code" do
it "can create a transaction with venmo_sdk_payment_method_code" do
result = Braintree::Transaction.sale(
:amount => "10.00",
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa)
+ :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa),
)
result.success?.should == true
result.transaction.credit_card_details.venmo_sdk?.should == false
end
it "errors when an invalid payment method code is passed" do
result = Braintree::Transaction.sale(
:amount => "10.00",
- :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 include("Invalid VenmoSDK payment method code")
result.errors.map(&:code).should include("91727")
end
@@ -6601,11 +6616,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.venmo_sdk?.should == false
end
@@ -6616,11 +6631,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
- }
+ },
)
result.success?.should == true
result.transaction.credit_card_details.venmo_sdk?.should == false
end
end
@@ -6628,11 +6643,11 @@
context "paypal" do
it "can create a transaction for a paypal account" do
result = Braintree::Transaction.sale(
:amount => "10.00",
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
)
result.success?.should == true
result.transaction.paypal_details.payer_email.should == "payer@example.com"
result.transaction.paypal_details.payment_id.should match(/PAY-\w+/)
result.transaction.paypal_details.authorization_id.should match(/AUTH-\w+/)
@@ -6643,11 +6658,11 @@
result = Braintree::Transaction.sale(
:amount => "10.00",
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
:options => {
:store_in_vault => true
- }
+ },
)
result.success?.should == true
result.transaction.paypal_details.token.should_not be_nil
result.transaction.paypal_details.payer_email.should == "payer@example.com"
result.transaction.paypal_details.payment_id.should match(/PAY-\w+/)
@@ -6656,21 +6671,21 @@
it "can create a transaction from a vaulted paypal account" do
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
- :customer_id => customer.id
+ :customer_id => customer.id,
)
result.should be_success
result.payment_method.should be_a(Braintree::PayPalAccount)
payment_method_token = result.payment_method.token
result = Braintree::Transaction.sale(
:amount => "100",
:customer_id => customer.id,
- :payment_method_token => payment_method_token
+ :payment_method_token => payment_method_token,
)
result.should be_success
result.transaction.paypal_details.token.should == payment_method_token
result.transaction.paypal_details.payer_email.should == "payer@example.com"
@@ -6681,11 +6696,11 @@
context "validation failure" do
it "returns a validation error if consent code and access token are omitted" do
nonce = nonce_for_paypal_account(:token => "TOKEN")
result = Braintree::Transaction.sale(
:amount => "10.00",
- :payment_method_nonce => nonce
+ :payment_method_nonce => nonce,
)
result.should_not be_success
result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount
end
end
@@ -6696,61 +6711,61 @@
@partner_merchant_gateway = Braintree::Gateway.new(
:merchant_id => "integration_merchant_public_id",
:public_key => "oauth_app_partner_user_public_key",
:private_key => "oauth_app_partner_user_private_key",
:environment => Braintree::Configuration.environment,
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
@customer = @partner_merchant_gateway.customer.create(
:first_name => "Joe",
:last_name => "Brown",
:company => "ExampleCo",
:email => "joe@example.com",
:phone => "312.555.1234",
:fax => "614.555.5678",
- :website => "www.example.com"
+ :website => "www.example.com",
).customer
@address = @partner_merchant_gateway.address.create(
:customer_id => @customer.id,
:first_name => "Testy",
- :last_name => "McTesterson"
+ :last_name => "McTesterson",
).address
@credit_card = @partner_merchant_gateway.credit_card.create(
:customer_id => @customer.id,
:cardholder_name => "Adam Davis",
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009",
:billing_address => {
:first_name => "Adam",
:last_name => "Davis",
:postal_code => "95131"
- }
+ },
).credit_card
oauth_gateway = Braintree::Gateway.new(
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
:merchant_public_id => "integration_merchant_id",
:scope => "grant_payment_method,shared_vault_transactions"
}).credentials.access_token
@granting_gateway = Braintree::Gateway.new(
:access_token => access_token,
- :logger => Logger.new("/dev/null")
+ :logger => Logger.new("/dev/null"),
)
end
it "oauth app details are returned on transaction created via nonce granting" do
grant_result = @granting_gateway.payment_method.grant(@credit_card.token, false)
result = Braintree::Transaction.sale(
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
- :amount => Braintree::Test::TransactionAmounts::Authorize
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
)
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
result.transaction.facilitated_details.merchant_name.should == "14ladders"
result.transaction.facilitated_details.payment_method_nonce.should == grant_result.payment_method_nonce.nonce
result.transaction.facilitator_details.should_not == nil
@@ -6762,11 +6777,11 @@
it "billing postal code is returned on transaction created via nonce granting when specified in the grant request" do
grant_result = @granting_gateway.payment_method.grant(@credit_card.token, :allow_vaulting => false, :include_billing_postal_code => true)
result = Braintree::Transaction.sale(
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
- :amount => Braintree::Test::TransactionAmounts::Authorize
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
)
result.transaction.billing_details.postal_code == "95131"
end
@@ -6774,21 +6789,21 @@
result = @granting_gateway.transaction.sale(
:shared_payment_method_token => @credit_card.token,
:shared_customer_id => @customer.id,
:shared_shipping_address_id => @address.id,
:shared_billing_address_id => @address.id,
- :amount => Braintree::Test::TransactionAmounts::Authorize
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
)
result.success?.should == true
result.transaction.shipping_details.first_name.should == @address.first_name
result.transaction.billing_details.first_name.should == @address.first_name
end
it "facilitated details are returned on transaction created via a shared_payment_method_token" do
result = @granting_gateway.transaction.sale(
:shared_payment_method_token => @credit_card.token,
- :amount => Braintree::Test::TransactionAmounts::Authorize
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
)
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
result.transaction.facilitated_details.merchant_name.should == "14ladders"
result.transaction.facilitated_details.payment_method_nonce.should == nil
result.transaction.facilitator_details.should_not == nil
@@ -6796,16 +6811,16 @@
result.transaction.facilitator_details.oauth_application_name.should == "PseudoShop"
end
it "facilitated details are returned on transaction created via a shared_payment_method_nonce" do
shared_nonce = @partner_merchant_gateway.payment_method_nonce.create(
- @credit_card.token
+ @credit_card.token,
).payment_method_nonce.nonce
result = @granting_gateway.transaction.sale(
:shared_payment_method_nonce => shared_nonce,
- :amount => Braintree::Test::TransactionAmounts::Authorize
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
)
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
result.transaction.facilitated_details.merchant_name.should == "14ladders"
result.transaction.facilitated_details.payment_method_nonce.should == nil
result.transaction.facilitator_details.should_not == nil
@@ -6814,11 +6829,11 @@
end
end
context "paypal here" do
it "gets the details of an auth/capture transaction" do
- result = Braintree::Transaction.find('paypal_here_auth_capture_id')
+ result = Braintree::Transaction.find("paypal_here_auth_capture_id")
result.payment_instrument_type.should eq(Braintree::PaymentInstrumentType::PayPalHere)
result.paypal_here_details.should_not be_nil
details = result.paypal_here_details
details.authorization_id.should_not be_nil
@@ -6831,19 +6846,19 @@
details.transaction_initiation_date.should_not be_nil
details.transaction_updated_date.should_not be_nil
end
it "gets the details of a sale transaction" do
- result = Braintree::Transaction.find('paypal_here_sale_id')
+ result = Braintree::Transaction.find("paypal_here_sale_id")
result.paypal_here_details.should_not be_nil
details = result.paypal_here_details
details.payment_id.should_not be_nil
end
it "gets the details of a refunded sale transaction" do
- result = Braintree::Transaction.find('paypal_here_refund_id')
+ result = Braintree::Transaction.find("paypal_here_refund_id")
result.paypal_here_details.should_not be_nil
details = result.paypal_here_details
details.refund_id.should_not be_nil
end
@@ -6864,11 +6879,11 @@
it "creates a transaction with a vaulted, non-tokenized credit card" do
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
- :customer_id => customer.id
+ :customer_id => customer.id,
)
payment_method_token = result.payment_method.token
result = Braintree::Transaction.sale(
:amount => "112.44",
@@ -6964,8 +6979,147 @@
installment = installments.find { |installment| installment.id == "#{sale_transaction.id}_INST_12" }
expect(installment.amount).to eq(BigDecimal("8.38"))
expect(installment.adjustments.map(&:amount)).to match_array([BigDecimal("-4.23")])
expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
+ end
+ end
+
+ describe "Adjust Authorization" do
+ let(:first_data_master_transaction_params) do
+ {
+ :merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
+ :amount => "75.50",
+ :credit_card => {
+ :number => "5105105105105100",
+ :expiration_date => "05/2012"
+ }
+ }
+ end
+ let(:first_data_visa_transaction_params) do
+ {
+ :merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
+ :amount => "75.50",
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "06/2009"
+ }
+ }
+ end
+ context "successful authorization" do
+ it "returns success response" do
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "85.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(true)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("85.50"))
+ end
+ end
+
+ context "unsuccessful authorization" do
+ it "returns failure, when processor does not support multi auth adjustment" do
+ initial_transaction = Braintree::Transaction.sale(
+ :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
+ :amount => "75.50",
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "06/2009"
+ },
+ )
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "85.50"
+ )
+
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportAuthAdjustment)
+ end
+
+ it "returns failure response, when adjusted amount submitted is zero" do
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "0.0"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AdjustmentAmountMustBeGreaterThanZero)
+ end
+
+ it "returns failure response, when adjusted amount submitted same as authorized amount" do
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "75.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
+ end
+
+ it "returns failure, when transaction status is not authorized" do
+ additional_params = {:options => {:submit_for_settlement => true}}
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "85.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
+ end
+
+ it "returns failure, when transaction authorization type final or undefined" do
+ additional_params = {:transaction_source => "recurring_first"}
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "85.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionIsNotEligibleForAdjustment)
+ end
+
+ it "returns failure, when processor does not support incremental auth" do
+ initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "85.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportIncrementalAuth)
+ end
+
+ it "returns failure, when processor does not support auth reversal" do
+ initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
+ expect(initial_transaction.success?).to eq(true)
+
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
+ initial_transaction.transaction.id, "65.50"
+ )
+
+ expect(adjustment_transaction.success?).to eq(false)
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialAuthReversal)
+ end
end
end
end