braintree 4.26.0 → 4.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/apple_pay_card.rb +4 -0
- data/lib/braintree/bin_data.rb +7 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +11 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +1 -0
- data/lib/braintree/customer_session_gateway.rb +11 -10
- data/lib/braintree/error_codes.rb +5 -104
- data/lib/braintree/google_pay_card.rb +4 -0
- data/lib/braintree/graphql/enums/recommendations.rb +2 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
- data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -0
- data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +2 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
- data/lib/braintree/graphql/types/payment_options.rb +2 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
- data/lib/braintree/merchant_account.rb +1 -25
- data/lib/braintree/merchant_account_gateway.rb +0 -81
- data/lib/braintree/meta_checkout_card.rb +8 -4
- data/lib/braintree/meta_checkout_token.rb +10 -6
- data/lib/braintree/payment_method_gateway.rb +3 -0
- data/lib/braintree/test/credit_card.rb +4 -0
- data/lib/braintree/transaction/apple_pay_details.rb +4 -0
- data/lib/braintree/transaction/credit_card_details.rb +8 -0
- data/lib/braintree/transaction/google_pay_details.rb +4 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
- data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
- data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
- data/lib/braintree/transaction.rb +0 -26
- data/lib/braintree/transaction_gateway.rb +9 -20
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +9 -4
- data/lib/braintree/webhook_notification.rb +0 -4
- data/lib/braintree/webhook_testing_gateway.rb +0 -33
- data/lib/braintree.rb +4 -3
- data/spec/integration/braintree/credit_card_spec.rb +101 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
- data/spec/integration/braintree/customer_session_spec.rb +59 -49
- data/spec/integration/braintree/customer_spec.rb +71 -4
- data/spec/integration/braintree/disbursement_spec.rb +1 -1
- data/spec/integration/braintree/merchant_account_spec.rb +0 -342
- data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
- data/spec/integration/braintree/payment_method_spec.rb +50 -3
- data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
- data/spec/integration/braintree/transaction_spec.rb +60 -328
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +22 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
- data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +19 -0
- data/spec/unit/braintree/transaction_spec.rb +8 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +0 -53
- data/spec/unit/credit_card_details_spec.rb +20 -0
- metadata +8 -7
- data/lib/braintree/merchant_account/business_details.rb +0 -17
- data/lib/braintree/merchant_account/funding_details.rb +0 -18
- data/lib/braintree/merchant_account/individual_details.rb +0 -20
- data/spec/unit/braintree/disbursement_spec.rb +0 -131
- data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -280,6 +280,58 @@ describe Braintree::Transaction do
|
|
280
280
|
expect(result.transaction.credit_card_details.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
281
281
|
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
282
282
|
end
|
283
|
+
|
284
|
+
it "sets the business field if the card is business" do
|
285
|
+
result = Braintree::Transaction.create(
|
286
|
+
:type => "sale",
|
287
|
+
:amount => 1_00,
|
288
|
+
:credit_card => {
|
289
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
290
|
+
:expiration_date => "05/2009"
|
291
|
+
},
|
292
|
+
)
|
293
|
+
expect(result.transaction.credit_card_details.business).to eq(Braintree::CreditCard::Business::Yes)
|
294
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "sets the consumer field if the card is consumer" do
|
298
|
+
result = Braintree::Transaction.create(
|
299
|
+
:type => "sale",
|
300
|
+
:amount => 1_00,
|
301
|
+
:credit_card => {
|
302
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
303
|
+
:expiration_date => "05/2009"
|
304
|
+
},
|
305
|
+
)
|
306
|
+
expect(result.transaction.credit_card_details.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
|
307
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
308
|
+
end
|
309
|
+
|
310
|
+
it "sets the corporate field if the card is corporate" do
|
311
|
+
result = Braintree::Transaction.create(
|
312
|
+
:type => "sale",
|
313
|
+
:amount => 1_00,
|
314
|
+
:credit_card => {
|
315
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
316
|
+
:expiration_date => "05/2009"
|
317
|
+
},
|
318
|
+
)
|
319
|
+
expect(result.transaction.credit_card_details.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
|
320
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "sets the purchase field if the card is purchase" do
|
324
|
+
result = Braintree::Transaction.create(
|
325
|
+
:type => "sale",
|
326
|
+
:amount => 1_00,
|
327
|
+
:credit_card => {
|
328
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
329
|
+
:expiration_date => "05/2009"
|
330
|
+
},
|
331
|
+
)
|
332
|
+
expect(result.transaction.credit_card_details.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
|
333
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
334
|
+
end
|
283
335
|
end
|
284
336
|
|
285
337
|
describe "sca_exemption" do
|
@@ -1987,108 +2039,6 @@ describe Braintree::Transaction do
|
|
1987
2039
|
end
|
1988
2040
|
end
|
1989
2041
|
|
1990
|
-
context "service fees" do
|
1991
|
-
it "allows specifying service fees" do
|
1992
|
-
result = Braintree::Transaction.create(
|
1993
|
-
:type => "sale",
|
1994
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1995
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
1996
|
-
:credit_card => {
|
1997
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1998
|
-
:expiration_date => "12/12",
|
1999
|
-
},
|
2000
|
-
:service_fee_amount => "1.00",
|
2001
|
-
)
|
2002
|
-
expect(result.success?).to eq(true)
|
2003
|
-
expect(result.transaction.service_fee_amount).to eq(BigDecimal("1.00"))
|
2004
|
-
end
|
2005
|
-
|
2006
|
-
it "raises an error if transaction merchant account is a master" do
|
2007
|
-
result = Braintree::Transaction.create(
|
2008
|
-
:type => "sale",
|
2009
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2010
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
2011
|
-
:credit_card => {
|
2012
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2013
|
-
:expiration_date => "12/12",
|
2014
|
-
},
|
2015
|
-
:service_fee_amount => "1.00",
|
2016
|
-
)
|
2017
|
-
expect(result.success?).to eq(false)
|
2018
|
-
expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
|
2019
|
-
expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(expected_error_code)
|
2020
|
-
end
|
2021
|
-
|
2022
|
-
it "raises an error if no service fee is present on a sub merchant account transaction" do
|
2023
|
-
result = Braintree::Transaction.create(
|
2024
|
-
:type => "sale",
|
2025
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2026
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
2027
|
-
:credit_card => {
|
2028
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2029
|
-
:expiration_date => "12/12",
|
2030
|
-
},
|
2031
|
-
)
|
2032
|
-
expect(result.success?).to eq(false)
|
2033
|
-
expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
|
2034
|
-
expect(result.errors.for(:transaction).on(:merchant_account_id)[0].code).to eq(expected_error_code)
|
2035
|
-
end
|
2036
|
-
|
2037
|
-
it "raises an error if service fee amount is negative" do
|
2038
|
-
result = Braintree::Transaction.create(
|
2039
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
2040
|
-
:service_fee_amount => "-1.00",
|
2041
|
-
)
|
2042
|
-
expect(result.success?).to eq(false)
|
2043
|
-
expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative)
|
2044
|
-
end
|
2045
|
-
|
2046
|
-
it "raises an error if service fee amount is invalid" do
|
2047
|
-
result = Braintree::Transaction.create(
|
2048
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
2049
|
-
:service_fee_amount => "invalid amount",
|
2050
|
-
)
|
2051
|
-
expect(result.success?).to eq(false)
|
2052
|
-
expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid)
|
2053
|
-
end
|
2054
|
-
end
|
2055
|
-
|
2056
|
-
context "escrow" do
|
2057
|
-
it "allows specifying transactions to be held for escrow" do
|
2058
|
-
result = Braintree::Transaction.create(
|
2059
|
-
:type => "sale",
|
2060
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2061
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
2062
|
-
:credit_card => {
|
2063
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2064
|
-
:expiration_date => "12/12",
|
2065
|
-
},
|
2066
|
-
:service_fee_amount => "10.00",
|
2067
|
-
:options => {:hold_in_escrow => true},
|
2068
|
-
)
|
2069
|
-
|
2070
|
-
expect(result.success?).to eq(true)
|
2071
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
|
2072
|
-
end
|
2073
|
-
|
2074
|
-
it "raises an error if transaction merchant account is a master" do
|
2075
|
-
result = Braintree::Transaction.create(
|
2076
|
-
:type => "sale",
|
2077
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2078
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
2079
|
-
:credit_card => {
|
2080
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2081
|
-
:expiration_date => "12/12",
|
2082
|
-
},
|
2083
|
-
:service_fee_amount => "1.00",
|
2084
|
-
:options => {:hold_in_escrow => true},
|
2085
|
-
)
|
2086
|
-
expect(result.success?).to eq(false)
|
2087
|
-
expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
|
2088
|
-
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(expected_error_code)
|
2089
|
-
end
|
2090
|
-
end
|
2091
|
-
|
2092
2042
|
context "client API" do
|
2093
2043
|
it "can create a transaction with a shared card nonce" do
|
2094
2044
|
nonce = nonce_for_new_payment_method(
|
@@ -2183,9 +2133,12 @@ describe Braintree::Transaction do
|
|
2183
2133
|
meta_checkout_card_details = result.transaction.meta_checkout_card_details
|
2184
2134
|
meta_checkout_card_details.should_not be_nil
|
2185
2135
|
meta_checkout_card_details.bin.should == "401288"
|
2136
|
+
meta_checkout_card_details.business.should == "Unknown"
|
2186
2137
|
meta_checkout_card_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2187
2138
|
meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
|
2139
|
+
meta_checkout_card_details.consumer.should == "Unknown"
|
2188
2140
|
meta_checkout_card_details.container_id.should == "container123"
|
2141
|
+
meta_checkout_card_details.corporate.should == "Unknown"
|
2189
2142
|
meta_checkout_card_details.customer_location.should == "US"
|
2190
2143
|
next_year = Date.today().next_year().year.to_s
|
2191
2144
|
meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
|
@@ -2197,6 +2150,7 @@ describe Braintree::Transaction do
|
|
2197
2150
|
meta_checkout_card_details.masked_number.should == "401288******1881"
|
2198
2151
|
meta_checkout_card_details.prepaid.should == "No"
|
2199
2152
|
meta_checkout_card_details.prepaid_reloadable.should == "Unknown"
|
2153
|
+
meta_checkout_card_details.purchase.should == "Unknown"
|
2200
2154
|
end
|
2201
2155
|
|
2202
2156
|
it "can create a transaction with a fake meta checkout token nonce" do
|
@@ -2212,9 +2166,12 @@ describe Braintree::Transaction do
|
|
2212
2166
|
|
2213
2167
|
meta_checkout_token_details.should_not be_nil
|
2214
2168
|
meta_checkout_token_details.bin.should == "401288"
|
2169
|
+
meta_checkout_token_details.business.should == "Unknown"
|
2215
2170
|
meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2216
2171
|
meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder"
|
2172
|
+
meta_checkout_token_details.consumer.should == "Unknown"
|
2217
2173
|
meta_checkout_token_details.container_id.should == "container123"
|
2174
|
+
meta_checkout_token_details.corporate.should == "Unknown"
|
2218
2175
|
meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
2219
2176
|
meta_checkout_token_details.customer_location.should == "US"
|
2220
2177
|
meta_checkout_token_details.ecommerce_indicator.should == "07"
|
@@ -2228,6 +2185,7 @@ describe Braintree::Transaction do
|
|
2228
2185
|
meta_checkout_token_details.masked_number.should == "401288******1881"
|
2229
2186
|
meta_checkout_token_details.prepaid.should == "No"
|
2230
2187
|
meta_checkout_token_details.prepaid_reloadable.should == "Unknown"
|
2188
|
+
meta_checkout_token_details.purchase.should == "Unknown"
|
2231
2189
|
end
|
2232
2190
|
|
2233
2191
|
it "can create a transaction with a fake apple pay nonce" do
|
@@ -3005,30 +2963,6 @@ describe Braintree::Transaction do
|
|
3005
2963
|
expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid)
|
3006
2964
|
end
|
3007
2965
|
|
3008
|
-
it "returns an error for transaction when the three_d_secure_pass_thru authentication_response is invalid" do
|
3009
|
-
result = Braintree::Transaction.create(
|
3010
|
-
:type => "sale",
|
3011
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
3012
|
-
:merchant_account_id => SpecHelper:: AdyenMerchantAccountId,
|
3013
|
-
:credit_card => {
|
3014
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
3015
|
-
:expiration_date => "12/12",
|
3016
|
-
},
|
3017
|
-
:three_d_secure_pass_thru => {
|
3018
|
-
:eci_flag => "05",
|
3019
|
-
:cavv => "some_cavv",
|
3020
|
-
:xid => "some_xid",
|
3021
|
-
:three_d_secure_version => "1.0.2",
|
3022
|
-
:authentication_response => "asdf",
|
3023
|
-
:directory_response => "Y",
|
3024
|
-
:cavv_algorithm => "2",
|
3025
|
-
:ds_transaction_id => "some_ds_id",
|
3026
|
-
},
|
3027
|
-
)
|
3028
|
-
expect(result.success?).to eq(false)
|
3029
|
-
expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid)
|
3030
|
-
end
|
3031
|
-
|
3032
2966
|
it "returns an error for transaction when the three_d_secure_pass_thru directory_response is invalid" do
|
3033
2967
|
result = Braintree::Transaction.create(
|
3034
2968
|
:type => "sale",
|
@@ -5739,7 +5673,6 @@ describe Braintree::Transaction do
|
|
5739
5673
|
end
|
5740
5674
|
end
|
5741
5675
|
|
5742
|
-
|
5743
5676
|
context "3rd party Card on File Network Token" do
|
5744
5677
|
it "Works with all params" do
|
5745
5678
|
params = {
|
@@ -6134,24 +6067,6 @@ describe Braintree::Transaction do
|
|
6134
6067
|
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement)
|
6135
6068
|
end
|
6136
6069
|
|
6137
|
-
context "service fees" do
|
6138
|
-
it "returns an error result if amount submitted for settlement is less than service fee amount" do
|
6139
|
-
transaction = Braintree::Transaction.create(
|
6140
|
-
:type => "sale",
|
6141
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6142
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
6143
|
-
:credit_card => {
|
6144
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6145
|
-
:expiration_date => "06/2009"
|
6146
|
-
},
|
6147
|
-
:service_fee_amount => "1.00",
|
6148
|
-
).transaction
|
6149
|
-
result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
|
6150
|
-
expect(result.success?).to eq(false)
|
6151
|
-
expect(result.errors.for(:transaction).on(:amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::SettlementAmountIsLessThanServiceFeeAmount)
|
6152
|
-
end
|
6153
|
-
end
|
6154
|
-
|
6155
6070
|
it "succeeds when industry data is provided" do
|
6156
6071
|
transaction = Braintree::Transaction.create(
|
6157
6072
|
:type => "sale",
|
@@ -6715,101 +6630,6 @@ describe Braintree::Transaction do
|
|
6715
6630
|
end
|
6716
6631
|
end
|
6717
6632
|
|
6718
|
-
describe "self.release_from_escrow" do
|
6719
|
-
it "returns the transaction if successful" do
|
6720
|
-
original_transaction = create_escrowed_transcation
|
6721
|
-
|
6722
|
-
result = Braintree::Transaction.release_from_escrow(original_transaction.id)
|
6723
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
|
6724
|
-
end
|
6725
|
-
|
6726
|
-
it "returns an error result if escrow_status is not HeldForEscrow" do
|
6727
|
-
transaction = Braintree::Transaction.sale!(
|
6728
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6729
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
6730
|
-
:credit_card => {
|
6731
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6732
|
-
:expiration_date => "05/2009"
|
6733
|
-
},
|
6734
|
-
:service_fee_amount => "1.00",
|
6735
|
-
)
|
6736
|
-
|
6737
|
-
expect(transaction.escrow_status).to be_nil
|
6738
|
-
|
6739
|
-
result = Braintree::Transaction.release_from_escrow(transaction.id)
|
6740
|
-
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotReleaseFromEscrow)
|
6741
|
-
end
|
6742
|
-
end
|
6743
|
-
|
6744
|
-
describe "self.release_from_escrow!" do
|
6745
|
-
it "returns the transaction when successful" do
|
6746
|
-
original_transaction = create_escrowed_transcation
|
6747
|
-
|
6748
|
-
transaction = Braintree::Transaction.release_from_escrow!(original_transaction.id)
|
6749
|
-
expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
|
6750
|
-
end
|
6751
|
-
|
6752
|
-
it "raises an error when transaction is not successful" do
|
6753
|
-
transaction = Braintree::Transaction.sale!(
|
6754
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6755
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
6756
|
-
:credit_card => {
|
6757
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6758
|
-
:expiration_date => "05/2009"
|
6759
|
-
},
|
6760
|
-
:service_fee_amount => "1.00",
|
6761
|
-
)
|
6762
|
-
|
6763
|
-
expect(transaction.escrow_status).to be_nil
|
6764
|
-
|
6765
|
-
expect do
|
6766
|
-
Braintree::Transaction.release_from_escrow!(transaction.id)
|
6767
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
6768
|
-
end
|
6769
|
-
end
|
6770
|
-
|
6771
|
-
describe "self.cancel_release" do
|
6772
|
-
it "returns the transaction if successful" do
|
6773
|
-
transaction = create_escrowed_transcation
|
6774
|
-
result = Braintree::Transaction.release_from_escrow(transaction.id)
|
6775
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
|
6776
|
-
|
6777
|
-
result = Braintree::Transaction.cancel_release(transaction.id)
|
6778
|
-
|
6779
|
-
expect(result.success?).to be(true)
|
6780
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::Held)
|
6781
|
-
end
|
6782
|
-
|
6783
|
-
it "returns an error result if escrow_status is not ReleasePending" do
|
6784
|
-
transaction = create_escrowed_transcation
|
6785
|
-
|
6786
|
-
result = Braintree::Transaction.cancel_release(transaction.id)
|
6787
|
-
|
6788
|
-
expect(result.success?).to be(false)
|
6789
|
-
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotCancelRelease)
|
6790
|
-
end
|
6791
|
-
end
|
6792
|
-
|
6793
|
-
describe "self.cancel_release!" do
|
6794
|
-
it "returns the transaction when release is cancelled" do
|
6795
|
-
transaction = create_escrowed_transcation
|
6796
|
-
result = Braintree::Transaction.release_from_escrow(transaction.id)
|
6797
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
|
6798
|
-
|
6799
|
-
transaction = Braintree::Transaction.cancel_release!(transaction.id)
|
6800
|
-
|
6801
|
-
expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::Held)
|
6802
|
-
end
|
6803
|
-
|
6804
|
-
it "raises an error when release cannot be cancelled" do
|
6805
|
-
transaction = create_escrowed_transcation
|
6806
|
-
|
6807
|
-
expect {
|
6808
|
-
transaction = Braintree::Transaction.cancel_release!(transaction.id)
|
6809
|
-
}.to raise_error(Braintree::ValidationsFailed)
|
6810
|
-
end
|
6811
|
-
end
|
6812
|
-
|
6813
6633
|
describe "self.credit" do
|
6814
6634
|
it "returns a successful result with type=credit if successful" do
|
6815
6635
|
result = Braintree::Transaction.credit(
|
@@ -7095,76 +6915,6 @@ describe Braintree::Transaction do
|
|
7095
6915
|
end
|
7096
6916
|
end
|
7097
6917
|
|
7098
|
-
describe "self.hold_in_escrow" do
|
7099
|
-
it "returns the transaction if successful" do
|
7100
|
-
result = Braintree::Transaction.create(
|
7101
|
-
:type => "sale",
|
7102
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7103
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
7104
|
-
:credit_card => {
|
7105
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7106
|
-
:expiration_date => "12/12",
|
7107
|
-
},
|
7108
|
-
:service_fee_amount => "10.00",
|
7109
|
-
)
|
7110
|
-
|
7111
|
-
expect(result.transaction.escrow_status).to be_nil
|
7112
|
-
result = Braintree::Transaction.hold_in_escrow(result.transaction.id)
|
7113
|
-
|
7114
|
-
expect(result.success?).to be(true)
|
7115
|
-
expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
|
7116
|
-
end
|
7117
|
-
|
7118
|
-
it "returns an error result if the transaction cannot be held in escrow" do
|
7119
|
-
transaction = Braintree::Transaction.sale!(
|
7120
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7121
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
7122
|
-
:credit_card => {
|
7123
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7124
|
-
:expiration_date => "05/2009"
|
7125
|
-
},
|
7126
|
-
)
|
7127
|
-
|
7128
|
-
result = Braintree::Transaction.hold_in_escrow(transaction.id)
|
7129
|
-
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotHoldInEscrow)
|
7130
|
-
end
|
7131
|
-
end
|
7132
|
-
|
7133
|
-
describe "self.hold_in_escrow!" do
|
7134
|
-
it "returns the transaction if successful" do
|
7135
|
-
result = Braintree::Transaction.create(
|
7136
|
-
:type => "sale",
|
7137
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7138
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
7139
|
-
:credit_card => {
|
7140
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7141
|
-
:expiration_date => "12/12",
|
7142
|
-
},
|
7143
|
-
:service_fee_amount => "10.00",
|
7144
|
-
)
|
7145
|
-
|
7146
|
-
expect(result.transaction.escrow_status).to be_nil
|
7147
|
-
transaction = Braintree::Transaction.hold_in_escrow!(result.transaction.id)
|
7148
|
-
|
7149
|
-
expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
|
7150
|
-
end
|
7151
|
-
|
7152
|
-
it "raises an error if the transaction cannot be held in escrow" do
|
7153
|
-
transaction = Braintree::Transaction.sale!(
|
7154
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7155
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
7156
|
-
:credit_card => {
|
7157
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7158
|
-
:expiration_date => "05/2009"
|
7159
|
-
},
|
7160
|
-
)
|
7161
|
-
|
7162
|
-
expect do
|
7163
|
-
Braintree::Transaction.hold_in_escrow!(transaction.id)
|
7164
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
7165
|
-
end
|
7166
|
-
end
|
7167
|
-
|
7168
6918
|
describe "self.void" do
|
7169
6919
|
it "returns a successful result if successful" do
|
7170
6920
|
transaction = Braintree::Transaction.sale!(
|
@@ -7374,24 +7124,6 @@ describe Braintree::Transaction do
|
|
7374
7124
|
Braintree::Transaction.find(transaction.id)
|
7375
7125
|
end
|
7376
7126
|
|
7377
|
-
def create_escrowed_transcation
|
7378
|
-
transaction = Braintree::Transaction.sale!(
|
7379
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7380
|
-
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
7381
|
-
:credit_card => {
|
7382
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7383
|
-
:expiration_date => "05/2009"
|
7384
|
-
},
|
7385
|
-
:service_fee_amount => "1.00",
|
7386
|
-
:options => {:hold_in_escrow => true},
|
7387
|
-
)
|
7388
|
-
|
7389
|
-
config = Braintree::Configuration.instantiate
|
7390
|
-
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
7391
|
-
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/escrow")
|
7392
|
-
Braintree::Transaction.find(transaction.id)
|
7393
|
-
end
|
7394
|
-
|
7395
7127
|
context "paypal" do
|
7396
7128
|
it "can create a transaction for a paypal account" do
|
7397
7129
|
result = Braintree::Transaction.sale(
|
data/spec/spec_helper.rb
CHANGED
@@ -34,13 +34,13 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
34
34
|
AibSwedenMaMerchantAccountId = "aib_swe_ma"
|
35
35
|
AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
|
36
36
|
CardProcessorBRLMerchantAccountId = "card_processor_brl"
|
37
|
+
CardProcessorBRLPayFacMerchantAccountId = "card_processor_brl_payfac"
|
37
38
|
DefaultMerchantAccountId = "sandbox_credit_card"
|
38
39
|
FakeAmexDirectMerchantAccountId = "fake_amex_direct_usd"
|
39
40
|
FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
|
40
41
|
FakeVenmoAccountMerchantAccountId = "fake_first_data_venmo_account"
|
41
42
|
HiperBRLMerchantAccountId = "hiper_brl"
|
42
43
|
NonDefaultMerchantAccountId = "sandbox_credit_card_non_default"
|
43
|
-
NonDefaultSubMerchantAccountId = "sandbox_sub_merchant_account"
|
44
44
|
PinlessDebitMerchantAccountId = "pinless_debit"
|
45
45
|
ThreeDSecureMerchantAccountId = "three_d_secure_merchant_account"
|
46
46
|
UsBankMerchantAccountId = "us_bank_merchant_account"
|
@@ -19,9 +19,12 @@ describe Braintree::ApplePayCard do
|
|
19
19
|
street_address: "123 Sesame Street",
|
20
20
|
},
|
21
21
|
:bin => "411111",
|
22
|
+
:business => "No",
|
22
23
|
:card_type => "Apple Pay - MasterCard",
|
23
24
|
:cardholder_name => "John Miller",
|
24
25
|
:commercial => "No",
|
26
|
+
:consumer => "No",
|
27
|
+
:corporate => "No",
|
25
28
|
:country_of_issuance => "USA",
|
26
29
|
:created_at => Time.now,
|
27
30
|
:customer_id => "cid1",
|
@@ -41,6 +44,7 @@ describe Braintree::ApplePayCard do
|
|
41
44
|
:prepaid => "No",
|
42
45
|
:prepaid_reloadable => "No",
|
43
46
|
:product_id => "MAC",
|
47
|
+
:purchase => "No",
|
44
48
|
:source_card_last4 => "1234",
|
45
49
|
:source_description => "blah",
|
46
50
|
:subscriptions => [
|
@@ -399,7 +399,7 @@ describe Braintree::Configuration do
|
|
399
399
|
|
400
400
|
it "is qa.braintreegateway.com for qa" do
|
401
401
|
Braintree::Configuration.environment = :qa
|
402
|
-
expect(Braintree::Configuration.instantiate.server).to eq("gateway.
|
402
|
+
expect(Braintree::Configuration.instantiate.server).to eq("gateway.qa.braintreepayments.com")
|
403
403
|
end
|
404
404
|
|
405
405
|
it "can by changed by configuring the production endpoint" do
|
@@ -25,7 +25,7 @@ describe Braintree::CreditCard do
|
|
25
25
|
:payment_method_nonce,
|
26
26
|
{:external_vault=>[:network_transaction_id]},
|
27
27
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
28
|
-
:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
28
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
29
29
|
{:billing_address => [
|
30
30
|
:company,
|
31
31
|
:country_code_alpha2,
|
@@ -73,7 +73,7 @@ describe Braintree::CreditCard do
|
|
73
73
|
:payment_method_nonce,
|
74
74
|
{:external_vault=>[:network_transaction_id]},
|
75
75
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
76
|
-
:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
76
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
77
77
|
{:billing_address => [
|
78
78
|
:company,
|
79
79
|
:country_code_alpha2,
|
@@ -271,4 +271,24 @@ describe Braintree::CreditCard do
|
|
271
271
|
card = Braintree::CreditCard._new(:gateway, {:prepaid_reloadable => "No"})
|
272
272
|
expect(card.prepaid_reloadable).to eq("No")
|
273
273
|
end
|
274
|
+
|
275
|
+
it "initializes business correctly" do
|
276
|
+
card = Braintree::CreditCard._new(:gateway, {:business => "No"})
|
277
|
+
expect(card.business).to eq("No")
|
278
|
+
end
|
279
|
+
|
280
|
+
it "initializes consumer correctly" do
|
281
|
+
card = Braintree::CreditCard._new(:gateway, {:consumer => "No"})
|
282
|
+
expect(card.consumer).to eq("No")
|
283
|
+
end
|
284
|
+
|
285
|
+
it "initializes corporate correctly" do
|
286
|
+
card = Braintree::CreditCard._new(:gateway, {:corporate => "No"})
|
287
|
+
expect(card.corporate).to eq("No")
|
288
|
+
end
|
289
|
+
|
290
|
+
it "initializes purchase correctly" do
|
291
|
+
card = Braintree::CreditCard._new(:gateway, {:purchase => "No"})
|
292
|
+
expect(card.purchase).to eq("No")
|
293
|
+
end
|
274
294
|
end
|
@@ -34,6 +34,7 @@ describe Braintree::CreditCardVerificationGateway do
|
|
34
34
|
expect(result.inspect).to include("status")
|
35
35
|
expect(result.inspect).to include("intended_transaction_source")
|
36
36
|
expect(result.inspect).to include("options")
|
37
|
+
expect(result.inspect).to include("account_information_inquiry")
|
37
38
|
expect(result.inspect).to include("account_type")
|
38
39
|
expect(result.inspect).to include("amount")
|
39
40
|
expect(result.inspect).to include("merchant_account_id")
|
@@ -88,32 +88,33 @@ describe Braintree::CustomerSessionGateway do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#get_customer_recommendations" do
|
91
|
-
let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id"
|
91
|
+
let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id"}) }
|
92
92
|
let(:response) do
|
93
93
|
{
|
94
94
|
data: {
|
95
|
-
|
95
|
+
generateCustomerRecommendations: {
|
96
|
+
sessionId: "session_id",
|
96
97
|
isInPayPalNetwork: true,
|
97
|
-
|
98
|
-
|
99
|
-
{paymentOption: "
|
98
|
+
paymentRecommendations:[
|
99
|
+
{paymentOption: "PAYPAL", recommendedPriority: 1},
|
100
|
+
{paymentOption: "VENMO", recommendedPriority: 2}
|
100
101
|
]
|
101
|
-
|
102
|
+
|
102
103
|
}
|
103
104
|
}
|
104
105
|
}
|
105
106
|
end
|
106
107
|
|
107
108
|
it "fetches customer recommendations" do
|
108
|
-
expected_variables = {"input" => {"sessionId" => "session_id"
|
109
|
+
expected_variables = {"input" => {"sessionId" => "session_id"}}
|
109
110
|
expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::GET_CUSTOMER_RECOMMENDATIONS, expected_variables).and_return(response)
|
110
111
|
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
|
111
112
|
|
112
113
|
result = customer_session_gateway.get_customer_recommendations(customer_recommendations_input)
|
113
114
|
expect(result).to be_a(Braintree::SuccessfulResult)
|
114
115
|
expect(result.customer_recommendations.is_in_paypal_network).to eq(true)
|
115
|
-
expect(result.customer_recommendations.recommendations.
|
116
|
-
expect(result.customer_recommendations.recommendations.
|
116
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].payment_option).to eq("PAYPAL")
|
117
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].recommended_priority).to eq(1)
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -105,7 +105,7 @@ describe Braintree::Customer do
|
|
105
105
|
:payment_method_nonce,
|
106
106
|
{:external_vault=>[:network_transaction_id]},
|
107
107
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
108
|
-
:fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
108
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
109
109
|
{:billing_address => [
|
110
110
|
:company,
|
111
111
|
:country_code_alpha2,
|
@@ -202,6 +202,7 @@ describe Braintree::Customer do
|
|
202
202
|
:payment_method_nonce,
|
203
203
|
{:external_vault=>[:network_transaction_id]},
|
204
204
|
{:options => match_array([
|
205
|
+
:account_information_inquiry,
|
205
206
|
:make_default,
|
206
207
|
:skip_advanced_fraud_checking,
|
207
208
|
:verification_merchant_account_id,
|
@@ -5,4 +5,24 @@ describe Braintree::GooglePayCard do
|
|
5
5
|
card = Braintree::GooglePayCard._new(:gateway, {:prepaid_reloadable => "No"})
|
6
6
|
expect(card.prepaid_reloadable).to eq("No")
|
7
7
|
end
|
8
|
+
|
9
|
+
it "initializes business correctly" do
|
10
|
+
card = Braintree::GooglePayCard._new(:gateway, {:business => "No"})
|
11
|
+
expect(card.business).to eq("No")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "initializes consumer correctly" do
|
15
|
+
card = Braintree::GooglePayCard._new(:gateway, {:consumer => "No"})
|
16
|
+
expect(card.consumer).to eq("No")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "initializes corporate correctly" do
|
20
|
+
card = Braintree::GooglePayCard._new(:gateway, {:corporate => "No"})
|
21
|
+
expect(card.corporate).to eq("No")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "initializes purchase correctly" do
|
25
|
+
card = Braintree::GooglePayCard._new(:gateway, {:purchase => "No"})
|
26
|
+
expect(card.purchase).to eq("No")
|
27
|
+
end
|
8
28
|
end
|