braintree 4.23.0 → 4.34.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address_gateway.rb +5 -0
  3. data/lib/braintree/apple_pay_card.rb +6 -0
  4. data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
  5. data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
  6. data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
  7. data/lib/braintree/bin_data.rb +8 -2
  8. data/lib/braintree/configuration.rb +1 -1
  9. data/lib/braintree/credit_card.rb +12 -5
  10. data/lib/braintree/credit_card_gateway.rb +1 -0
  11. data/lib/braintree/credit_card_verification_gateway.rb +5 -2
  12. data/lib/braintree/customer_session_gateway.rb +195 -0
  13. data/lib/braintree/dispute.rb +1 -0
  14. data/lib/braintree/error_codes.rb +58 -104
  15. data/lib/braintree/error_result.rb +1 -1
  16. data/lib/braintree/errors.rb +2 -1
  17. data/lib/braintree/gateway.rb +12 -0
  18. data/lib/braintree/google_pay_card.rb +5 -0
  19. data/lib/braintree/graphql/enums/recommendations.rb +9 -0
  20. data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
  21. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
  22. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
  23. data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
  24. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  25. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  26. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  27. data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
  28. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
  29. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
  30. data/lib/braintree/graphql/types/payment_options.rb +35 -0
  31. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  32. data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
  33. data/lib/braintree/graphql_client.rb +16 -0
  34. data/lib/braintree/merchant_account.rb +1 -25
  35. data/lib/braintree/merchant_account_gateway.rb +0 -81
  36. data/lib/braintree/meta_checkout_card.rb +11 -6
  37. data/lib/braintree/meta_checkout_token.rb +11 -6
  38. data/lib/braintree/payment_method_gateway.rb +9 -0
  39. data/lib/braintree/paypal_payment_resource.rb +22 -0
  40. data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
  41. data/lib/braintree/successful_result.rb +3 -0
  42. data/lib/braintree/test/credit_card.rb +5 -0
  43. data/lib/braintree/transaction/apple_pay_details.rb +7 -0
  44. data/lib/braintree/transaction/credit_card_details.rb +22 -10
  45. data/lib/braintree/transaction/google_pay_details.rb +16 -10
  46. data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
  47. data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
  48. data/lib/braintree/transaction/paypal_details.rb +2 -0
  49. data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
  50. data/lib/braintree/transaction.rb +3 -26
  51. data/lib/braintree/transaction_gateway.rb +52 -31
  52. data/lib/braintree/us_bank_account_verification.rb +3 -1
  53. data/lib/braintree/version.rb +1 -1
  54. data/lib/braintree/visa_checkout_card.rb +10 -5
  55. data/lib/braintree/webhook_notification.rb +1 -4
  56. data/lib/braintree/webhook_testing_gateway.rb +16 -33
  57. data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
  58. data/lib/braintree/xml/parser.rb +4 -4
  59. data/lib/braintree.rb +21 -4
  60. data/spec/integration/braintree/advanced_search_spec.rb +7 -4
  61. data/spec/integration/braintree/apple_pay_spec.rb +6 -7
  62. data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
  63. data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
  64. data/spec/integration/braintree/credit_card_spec.rb +115 -1
  65. data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
  66. data/spec/integration/braintree/customer_session_spec.rb +154 -0
  67. data/spec/integration/braintree/customer_spec.rb +94 -10
  68. data/spec/integration/braintree/disbursement_spec.rb +1 -1
  69. data/spec/integration/braintree/dispute_spec.rb +13 -2
  70. data/spec/integration/braintree/merchant_account_spec.rb +19 -359
  71. data/spec/integration/braintree/merchant_spec.rb +4 -4
  72. data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
  73. data/spec/integration/braintree/payment_method_spec.rb +57 -7
  74. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
  75. data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
  76. data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
  77. data/spec/integration/braintree/transaction_search_spec.rb +38 -33
  78. data/spec/integration/braintree/transaction_spec.rb +266 -350
  79. data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
  80. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
  81. data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
  82. data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
  83. data/spec/spec_helper.rb +46 -12
  84. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
  85. data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
  86. data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
  87. data/spec/unit/braintree/client_token_spec.rb +11 -0
  88. data/spec/unit/braintree/configuration_spec.rb +1 -1
  89. data/spec/unit/braintree/credit_card_spec.rb +27 -2
  90. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  91. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
  92. data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
  93. data/spec/unit/braintree/customer_spec.rb +2 -1
  94. data/spec/unit/braintree/dispute_spec.rb +6 -0
  95. data/spec/unit/braintree/error_result_spec.rb +28 -0
  96. data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
  97. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
  98. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
  99. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  100. data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
  101. data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
  102. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +107 -0
  103. data/spec/unit/braintree/graphql_client_spec.rb +37 -0
  104. data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
  105. data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
  106. data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
  107. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  108. data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
  109. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
  110. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
  111. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
  112. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
  113. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
  114. data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
  115. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
  116. data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
  117. data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
  118. data/spec/unit/braintree/transaction_spec.rb +66 -0
  119. data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
  120. data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
  121. data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
  122. data/spec/unit/braintree/xml/parser_spec.rb +57 -0
  123. data/spec/unit/credit_card_details_spec.rb +28 -0
  124. metadata +49 -10
  125. data/lib/braintree/merchant_account/business_details.rb +0 -17
  126. data/lib/braintree/merchant_account/funding_details.rb +0 -18
  127. data/lib/braintree/merchant_account/individual_details.rb +0 -20
  128. data/lib/ssl/securetrust_ca.crt +0 -44
  129. data/spec/unit/braintree/disbursement_spec.rb +0 -131
  130. data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -267,6 +267,71 @@ describe Braintree::Transaction do
267
267
  expect(result.transaction.credit_card_details.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
268
268
  expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
269
269
  end
270
+
271
+ it "sets the prepaid_reloadable field if the card is prepaid reloadable" do
272
+ result = Braintree::Transaction.create(
273
+ :type => "sale",
274
+ :amount => 1_00,
275
+ :credit_card => {
276
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::PrepaidReloadable,
277
+ :expiration_date => "05/2009"
278
+ },
279
+ )
280
+ expect(result.transaction.credit_card_details.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
281
+ expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
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
270
335
  end
271
336
 
272
337
  describe "sca_exemption" do
@@ -1151,27 +1216,32 @@ describe Braintree::Transaction do
1151
1216
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
1152
1217
  :logger => Logger.new("/dev/null"),
1153
1218
  )
1154
- result = gateway.merchant.create(
1155
- :email => "name@email.com",
1156
- :country_code_alpha3 => "GBR",
1157
- :payment_methods => ["credit_card", "paypal"],
1219
+
1220
+ code = Braintree::OAuthTestHelper.create_grant(gateway, {
1221
+ :merchant_public_id => "partner_merchant_id",
1222
+ :scope => "read_write"
1223
+ })
1224
+
1225
+ result = gateway.oauth.create_token_from_code(
1226
+ :code => code,
1227
+ :scope => "read_write",
1158
1228
  )
1159
1229
 
1160
- gateway = Braintree::Gateway.new(
1230
+ merchant_gateway = Braintree::Gateway.new(
1161
1231
  :access_token => result.credentials.access_token,
1162
1232
  :logger => Logger.new("/dev/null"),
1163
1233
  )
1164
1234
 
1165
- result = gateway.transaction.create(
1235
+ transaction_result = merchant_gateway.transaction.create(
1166
1236
  :type => "sale",
1167
- :amount => "4000.00",
1237
+ :amount => "5001.00",
1168
1238
  :credit_card => {
1169
1239
  :number => Braintree::Test::CreditCardNumbers::Visa,
1170
1240
  :expiration_date => "05/2020"
1171
1241
  },
1172
1242
  )
1173
- expect(result.success?).to eq(false)
1174
- expect(result.transaction.gateway_rejection_reason).to eq(Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete)
1243
+ expect(transaction_result.success?).to eq(false)
1244
+ expect(transaction_result.transaction.gateway_rejection_reason).to eq(Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete)
1175
1245
  end
1176
1246
 
1177
1247
  it "exposes the avs gateway rejection reason" do
@@ -1974,108 +2044,6 @@ describe Braintree::Transaction do
1974
2044
  end
1975
2045
  end
1976
2046
 
1977
- context "service fees" do
1978
- it "allows specifying service fees" do
1979
- result = Braintree::Transaction.create(
1980
- :type => "sale",
1981
- :amount => Braintree::Test::TransactionAmounts::Authorize,
1982
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
1983
- :credit_card => {
1984
- :number => Braintree::Test::CreditCardNumbers::Visa,
1985
- :expiration_date => "12/12",
1986
- },
1987
- :service_fee_amount => "1.00",
1988
- )
1989
- expect(result.success?).to eq(true)
1990
- expect(result.transaction.service_fee_amount).to eq(BigDecimal("1.00"))
1991
- end
1992
-
1993
- it "raises an error if transaction merchant account is a master" do
1994
- result = Braintree::Transaction.create(
1995
- :type => "sale",
1996
- :amount => Braintree::Test::TransactionAmounts::Authorize,
1997
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1998
- :credit_card => {
1999
- :number => Braintree::Test::CreditCardNumbers::Visa,
2000
- :expiration_date => "12/12",
2001
- },
2002
- :service_fee_amount => "1.00",
2003
- )
2004
- expect(result.success?).to eq(false)
2005
- expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
2006
- expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(expected_error_code)
2007
- end
2008
-
2009
- it "raises an error if no service fee is present on a sub merchant account transaction" do
2010
- result = Braintree::Transaction.create(
2011
- :type => "sale",
2012
- :amount => Braintree::Test::TransactionAmounts::Authorize,
2013
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
2014
- :credit_card => {
2015
- :number => Braintree::Test::CreditCardNumbers::Visa,
2016
- :expiration_date => "12/12",
2017
- },
2018
- )
2019
- expect(result.success?).to eq(false)
2020
- expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
2021
- expect(result.errors.for(:transaction).on(:merchant_account_id)[0].code).to eq(expected_error_code)
2022
- end
2023
-
2024
- it "raises an error if service fee amount is negative" do
2025
- result = Braintree::Transaction.create(
2026
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
2027
- :service_fee_amount => "-1.00",
2028
- )
2029
- expect(result.success?).to eq(false)
2030
- expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative)
2031
- end
2032
-
2033
- it "raises an error if service fee amount is invalid" do
2034
- result = Braintree::Transaction.create(
2035
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
2036
- :service_fee_amount => "invalid amount",
2037
- )
2038
- expect(result.success?).to eq(false)
2039
- expect(result.errors.for(:transaction).on(:service_fee_amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid)
2040
- end
2041
- end
2042
-
2043
- context "escrow" do
2044
- it "allows specifying transactions to be held for escrow" do
2045
- result = Braintree::Transaction.create(
2046
- :type => "sale",
2047
- :amount => Braintree::Test::TransactionAmounts::Authorize,
2048
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
2049
- :credit_card => {
2050
- :number => Braintree::Test::CreditCardNumbers::Visa,
2051
- :expiration_date => "12/12",
2052
- },
2053
- :service_fee_amount => "10.00",
2054
- :options => {:hold_in_escrow => true},
2055
- )
2056
-
2057
- expect(result.success?).to eq(true)
2058
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
2059
- end
2060
-
2061
- it "raises an error if transaction merchant account is a master" do
2062
- result = Braintree::Transaction.create(
2063
- :type => "sale",
2064
- :amount => Braintree::Test::TransactionAmounts::Authorize,
2065
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
2066
- :credit_card => {
2067
- :number => Braintree::Test::CreditCardNumbers::Visa,
2068
- :expiration_date => "12/12",
2069
- },
2070
- :service_fee_amount => "1.00",
2071
- :options => {:hold_in_escrow => true},
2072
- )
2073
- expect(result.success?).to eq(false)
2074
- expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
2075
- expect(result.errors.for(:transaction).on(:base)[0].code).to eq(expected_error_code)
2076
- end
2077
- end
2078
-
2079
2047
  context "client API" do
2080
2048
  it "can create a transaction with a shared card nonce" do
2081
2049
  nonce = nonce_for_new_payment_method(
@@ -2170,9 +2138,12 @@ describe Braintree::Transaction do
2170
2138
  meta_checkout_card_details = result.transaction.meta_checkout_card_details
2171
2139
  meta_checkout_card_details.should_not be_nil
2172
2140
  meta_checkout_card_details.bin.should == "401288"
2141
+ meta_checkout_card_details.business.should == "Unknown"
2173
2142
  meta_checkout_card_details.card_type.should == Braintree::CreditCard::CardType::Visa
2174
2143
  meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
2144
+ meta_checkout_card_details.consumer.should == "Unknown"
2175
2145
  meta_checkout_card_details.container_id.should == "container123"
2146
+ meta_checkout_card_details.corporate.should == "Unknown"
2176
2147
  meta_checkout_card_details.customer_location.should == "US"
2177
2148
  next_year = Date.today().next_year().year.to_s
2178
2149
  meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
@@ -2183,6 +2154,8 @@ describe Braintree::Transaction do
2183
2154
  meta_checkout_card_details.last_4.should == "1881"
2184
2155
  meta_checkout_card_details.masked_number.should == "401288******1881"
2185
2156
  meta_checkout_card_details.prepaid.should == "No"
2157
+ meta_checkout_card_details.prepaid_reloadable.should == "Unknown"
2158
+ meta_checkout_card_details.purchase.should == "Unknown"
2186
2159
  end
2187
2160
 
2188
2161
  it "can create a transaction with a fake meta checkout token nonce" do
@@ -2198,9 +2171,12 @@ describe Braintree::Transaction do
2198
2171
 
2199
2172
  meta_checkout_token_details.should_not be_nil
2200
2173
  meta_checkout_token_details.bin.should == "401288"
2174
+ meta_checkout_token_details.business.should == "Unknown"
2201
2175
  meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa
2202
2176
  meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder"
2177
+ meta_checkout_token_details.consumer.should == "Unknown"
2203
2178
  meta_checkout_token_details.container_id.should == "container123"
2179
+ meta_checkout_token_details.corporate.should == "Unknown"
2204
2180
  meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
2205
2181
  meta_checkout_token_details.customer_location.should == "US"
2206
2182
  meta_checkout_token_details.ecommerce_indicator.should == "07"
@@ -2213,6 +2189,8 @@ describe Braintree::Transaction do
2213
2189
  meta_checkout_token_details.last_4.should == "1881"
2214
2190
  meta_checkout_token_details.masked_number.should == "401288******1881"
2215
2191
  meta_checkout_token_details.prepaid.should == "No"
2192
+ meta_checkout_token_details.prepaid_reloadable.should == "Unknown"
2193
+ meta_checkout_token_details.purchase.should == "Unknown"
2216
2194
  end
2217
2195
 
2218
2196
  it "can create a transaction with a fake apple pay nonce" do
@@ -2241,6 +2219,37 @@ describe Braintree::Transaction do
2241
2219
  expect(apple_pay_details.commercial).not_to be_nil
2242
2220
  expect(apple_pay_details.payroll).not_to be_nil
2243
2221
  expect(apple_pay_details.product_id).not_to be_nil
2222
+ expect(apple_pay_details.is_device_token).to eq(true)
2223
+ end
2224
+
2225
+ it "can create a transaction with a fake apple pay mpan nonce" do
2226
+ result = Braintree::Transaction.create(
2227
+ :type => "sale",
2228
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
2229
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayMpan,
2230
+ )
2231
+ expect(result.success?).to eq(true)
2232
+ expect(result.transaction).not_to be_nil
2233
+ apple_pay_details = result.transaction.apple_pay_details
2234
+ expect(apple_pay_details).not_to be_nil
2235
+ expect(apple_pay_details.bin).not_to be_nil
2236
+ expect(apple_pay_details.card_type).to eq(Braintree::ApplePayCard::CardType::Visa)
2237
+ expect(apple_pay_details.payment_instrument_name).to eq("Visa 2006")
2238
+ expect(apple_pay_details.source_description).to eq("Visa 2006")
2239
+ expect(apple_pay_details.expiration_month.to_i).to be > 0
2240
+ expect(apple_pay_details.expiration_year.to_i).to be > 0
2241
+ expect(apple_pay_details.cardholder_name).not_to be_nil
2242
+ expect(apple_pay_details.image_url).not_to be_nil
2243
+ expect(apple_pay_details.token).to be_nil
2244
+ expect(apple_pay_details.prepaid).not_to be_nil
2245
+ expect(apple_pay_details.healthcare).not_to be_nil
2246
+ expect(apple_pay_details.debit).not_to be_nil
2247
+ expect(apple_pay_details.durbin_regulated).not_to be_nil
2248
+ expect(apple_pay_details.commercial).not_to be_nil
2249
+ expect(apple_pay_details.payroll).not_to be_nil
2250
+ expect(apple_pay_details.product_id).not_to be_nil
2251
+ expect(apple_pay_details.merchant_token_identifier).not_to be_nil
2252
+ expect(apple_pay_details.is_device_token).to eq(false)
2244
2253
  end
2245
2254
 
2246
2255
  it "can create a vaulted transaction with a fake apple pay nonce" do
@@ -2333,7 +2342,8 @@ describe Braintree::Transaction do
2333
2342
  expect(google_pay_details.virtual_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
2334
2343
  expect(google_pay_details.last_4).to eq("4444")
2335
2344
  expect(google_pay_details.virtual_card_last_4).to eq("4444")
2336
- expect(google_pay_details.source_description).to eq("MasterCard 4444")
2345
+ expect(google_pay_details.source_card_last_4).to eq("0005")
2346
+ expect(google_pay_details.source_description).to eq("MasterCard 0005")
2337
2347
  expect(google_pay_details.expiration_month.to_i).to be > 0
2338
2348
  expect(google_pay_details.expiration_year.to_i).to be > 0
2339
2349
  expect(google_pay_details.google_transaction_id).to eq("google_transaction_id")
@@ -2990,30 +3000,6 @@ describe Braintree::Transaction do
2990
3000
  expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid)
2991
3001
  end
2992
3002
 
2993
- it "returns an error for transaction when the three_d_secure_pass_thru authentication_response is invalid" do
2994
- result = Braintree::Transaction.create(
2995
- :type => "sale",
2996
- :amount => Braintree::Test::TransactionAmounts::Authorize,
2997
- :merchant_account_id => SpecHelper:: AdyenMerchantAccountId,
2998
- :credit_card => {
2999
- :number => Braintree::Test::CreditCardNumbers::Visa,
3000
- :expiration_date => "12/12",
3001
- },
3002
- :three_d_secure_pass_thru => {
3003
- :eci_flag => "05",
3004
- :cavv => "some_cavv",
3005
- :xid => "some_xid",
3006
- :three_d_secure_version => "1.0.2",
3007
- :authentication_response => "asdf",
3008
- :directory_response => "Y",
3009
- :cavv_algorithm => "2",
3010
- :ds_transaction_id => "some_ds_id",
3011
- },
3012
- )
3013
- expect(result.success?).to eq(false)
3014
- expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid)
3015
- end
3016
-
3017
3003
  it "returns an error for transaction when the three_d_secure_pass_thru directory_response is invalid" do
3018
3004
  result = Braintree::Transaction.create(
3019
3005
  :type => "sale",
@@ -3058,8 +3044,9 @@ describe Braintree::Transaction do
3058
3044
  :ds_transaction_id => "some_ds_id",
3059
3045
  },
3060
3046
  )
3047
+
3061
3048
  expect(result.success?).to eq(false)
3062
- expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv_algorithm)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureCavvAlgorithmIsInvalid)
3049
+ expect(result.errors.for(:transaction).for(:credit_card).on(:cvv)[0].code).to eq(Braintree::ErrorCodes::CreditCard::CvvIsRequired)
3063
3050
  end
3064
3051
  end
3065
3052
 
@@ -3419,13 +3406,13 @@ describe Braintree::Transaction do
3419
3406
  config = Braintree::Configuration.instantiate
3420
3407
  config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
3421
3408
  result = Braintree::Transaction.refund(transaction.id, :amount => "2046.00")
3422
- expect(result.success?).to eq(false)
3409
+ expect(result.success?).to eq(true)
3423
3410
  expect(result.transaction.id).to match(/^\w{6,}$/)
3424
3411
  expect(result.transaction.type).to eq("credit")
3425
- expect(result.transaction.status).to eq(Braintree::Transaction::Status::ProcessorDeclined)
3426
- expect(result.transaction.processor_response_code).to eq("2046")
3427
- expect(result.transaction.processor_response_text).to eq("Declined")
3428
- expect(result.transaction.processor_response_type).to eq(Braintree::ProcessorResponseTypes::SoftDeclined)
3412
+ expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
3413
+ expect(result.transaction.processor_response_code).to eq("1005")
3414
+ expect(result.transaction.processor_response_text).to eq("Auth Declined but Settlement Captured")
3415
+ expect(result.transaction.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
3429
3416
  expect(result.transaction.additional_processor_response).to eq("2046 : Declined")
3430
3417
  end
3431
3418
 
@@ -3439,15 +3426,15 @@ describe Braintree::Transaction do
3439
3426
  )
3440
3427
  config = Braintree::Configuration.instantiate
3441
3428
  config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
3442
- result = Braintree::Transaction.refund(transaction.id, :amount => "2009.00")
3429
+ result = Braintree::Transaction.refund(transaction.id, :amount => "2004.00")
3443
3430
  expect(result.success?).to eq(false)
3444
3431
  expect(result.transaction.id).to match(/^\w{6,}$/)
3445
3432
  expect(result.transaction.type).to eq("credit")
3446
3433
  expect(result.transaction.status).to eq(Braintree::Transaction::Status::ProcessorDeclined)
3447
- expect(result.transaction.processor_response_code).to eq("2009")
3448
- expect(result.transaction.processor_response_text).to eq("No Such Issuer")
3434
+ expect(result.transaction.processor_response_code).to eq("2004")
3435
+ expect(result.transaction.processor_response_text).to eq("Expired Card")
3449
3436
  expect(result.transaction.processor_response_type).to eq(Braintree::ProcessorResponseTypes::HardDeclined)
3450
- expect(result.transaction.additional_processor_response).to eq("2009 : No Such Issuer")
3437
+ expect(result.transaction.additional_processor_response).to eq("2004 : Expired Card")
3451
3438
  end
3452
3439
  end
3453
3440
 
@@ -5321,6 +5308,61 @@ describe Braintree::Transaction do
5321
5308
  expect(transaction.shipping_details.international_phone[:national_number]).to eq("3121234567")
5322
5309
  end
5323
5310
 
5311
+ it "accepts processing_merchant_category_code" do
5312
+ result = Braintree::Transaction.sale(
5313
+ :amount => "100.00",
5314
+ :credit_card => {
5315
+ :number => "4111111111111111",
5316
+ :expiration_date => "05/2028"
5317
+ },
5318
+ :processing_merchant_category_code => "5411",
5319
+ )
5320
+
5321
+ expect(result.success?).to eq(true)
5322
+ end
5323
+
5324
+ it "returns validation error for a too long processing_merchant_category_code" do
5325
+ result = Braintree::Transaction.sale(
5326
+ :amount => "100.00",
5327
+ :credit_card => {
5328
+ :number => "4111111111111111",
5329
+ :expiration_date => "05/2028"
5330
+ },
5331
+ :processing_merchant_category_code => "54111",
5332
+ )
5333
+
5334
+ expect(result.success?).to eq(false)
5335
+ expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
5336
+ end
5337
+
5338
+ it "returns validation error for an alphanumeric processing_merchant_category_code" do
5339
+ result = Braintree::Transaction.sale(
5340
+ :amount => "100.00",
5341
+ :credit_card => {
5342
+ :number => "4111111111111111",
5343
+ :expiration_date => "05/2028"
5344
+ },
5345
+ :processing_merchant_category_code => "541A",
5346
+ )
5347
+
5348
+ expect(result.success?).to eq(false)
5349
+ expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
5350
+ end
5351
+
5352
+ it "returns validation error for a too short processing_merchant_category_code" do
5353
+ result = Braintree::Transaction.sale(
5354
+ :amount => "100.00",
5355
+ :credit_card => {
5356
+ :number => "4111111111111111",
5357
+ :expiration_date => "05/2028"
5358
+ },
5359
+ :processing_merchant_category_code => "541",
5360
+ )
5361
+
5362
+ expect(result.success?).to eq(false)
5363
+ expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
5364
+ end
5365
+
5324
5366
  it "allows merchant account to be specified" do
5325
5367
  result = Braintree::Transaction.sale(
5326
5368
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -5724,7 +5766,6 @@ describe Braintree::Transaction do
5724
5766
  end
5725
5767
  end
5726
5768
 
5727
-
5728
5769
  context "3rd party Card on File Network Token" do
5729
5770
  it "Works with all params" do
5730
5771
  params = {
@@ -5765,6 +5806,32 @@ describe Braintree::Transaction do
5765
5806
  expect(result.success?).to eq(false)
5766
5807
  expect(result.errors.for(:transaction).for(:credit_card).map { |e| e.code }.sort).to eq [Braintree::ErrorCodes::CreditCard::NetworkTokenizationAttributeCryptogramIsRequired]
5767
5808
  end
5809
+
5810
+ it "Works with missing cryptogram and specified previous_network_transaction_id" do
5811
+ params = {
5812
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
5813
+ :credit_card => {
5814
+ :number => Braintree::Test::CreditCardNumbers::Visa,
5815
+ :expiration_date => "05/2009",
5816
+ :network_tokenization_attributes => {
5817
+ :ecommerce_indicator => "05",
5818
+ :token_requestor_id => "45310020105"
5819
+ },
5820
+ },
5821
+ :external_vault => {
5822
+ :status => Braintree::Transaction::ExternalVault::Status::Vaulted,
5823
+ :previous_network_transaction_id => "123456789012345"
5824
+ },
5825
+ :transaction_source => "recurring"
5826
+ }
5827
+ result = Braintree::Transaction.sale(params)
5828
+ expect(result.success?).to eq true
5829
+ expect(result.transaction.status).to eq Braintree::Transaction::Status::Authorized
5830
+ expect(result.transaction.processed_with_network_token?).to eq true
5831
+
5832
+ network_token_details = result.transaction.network_token_details
5833
+ expect(network_token_details.is_network_tokenized?).to eq true
5834
+ end
5768
5835
  end
5769
5836
 
5770
5837
  xit "Amex Pay with Points" do
@@ -5914,7 +5981,8 @@ describe Braintree::Transaction do
5914
5981
  end
5915
5982
 
5916
5983
  context "Pinless debit transaction" do
5917
- it "succesfully submits for settlement" do
5984
+ xit "succesfully submits for settlement" do
5985
+ # Flaky test
5918
5986
  result = Braintree::Transaction.sale(
5919
5987
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5920
5988
  :merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
@@ -6093,24 +6161,6 @@ describe Braintree::Transaction do
6093
6161
  expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement)
6094
6162
  end
6095
6163
 
6096
- context "service fees" do
6097
- it "returns an error result if amount submitted for settlement is less than service fee amount" do
6098
- transaction = Braintree::Transaction.create(
6099
- :type => "sale",
6100
- :amount => Braintree::Test::TransactionAmounts::Authorize,
6101
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
6102
- :credit_card => {
6103
- :number => Braintree::Test::CreditCardNumbers::Visa,
6104
- :expiration_date => "06/2009"
6105
- },
6106
- :service_fee_amount => "1.00",
6107
- ).transaction
6108
- result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
6109
- expect(result.success?).to eq(false)
6110
- expect(result.errors.for(:transaction).on(:amount)[0].code).to eq(Braintree::ErrorCodes::Transaction::SettlementAmountIsLessThanServiceFeeAmount)
6111
- end
6112
- end
6113
-
6114
6164
  it "succeeds when industry data is provided" do
6115
6165
  transaction = Braintree::Transaction.create(
6116
6166
  :type => "sale",
@@ -6674,101 +6724,6 @@ describe Braintree::Transaction do
6674
6724
  end
6675
6725
  end
6676
6726
 
6677
- describe "self.release_from_escrow" do
6678
- it "returns the transaction if successful" do
6679
- original_transaction = create_escrowed_transcation
6680
-
6681
- result = Braintree::Transaction.release_from_escrow(original_transaction.id)
6682
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
6683
- end
6684
-
6685
- it "returns an error result if escrow_status is not HeldForEscrow" do
6686
- transaction = Braintree::Transaction.sale!(
6687
- :amount => Braintree::Test::TransactionAmounts::Authorize,
6688
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
6689
- :credit_card => {
6690
- :number => Braintree::Test::CreditCardNumbers::Visa,
6691
- :expiration_date => "05/2009"
6692
- },
6693
- :service_fee_amount => "1.00",
6694
- )
6695
-
6696
- expect(transaction.escrow_status).to be_nil
6697
-
6698
- result = Braintree::Transaction.release_from_escrow(transaction.id)
6699
- expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotReleaseFromEscrow)
6700
- end
6701
- end
6702
-
6703
- describe "self.release_from_escrow!" do
6704
- it "returns the transaction when successful" do
6705
- original_transaction = create_escrowed_transcation
6706
-
6707
- transaction = Braintree::Transaction.release_from_escrow!(original_transaction.id)
6708
- expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
6709
- end
6710
-
6711
- it "raises an error when transaction is not successful" do
6712
- transaction = Braintree::Transaction.sale!(
6713
- :amount => Braintree::Test::TransactionAmounts::Authorize,
6714
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
6715
- :credit_card => {
6716
- :number => Braintree::Test::CreditCardNumbers::Visa,
6717
- :expiration_date => "05/2009"
6718
- },
6719
- :service_fee_amount => "1.00",
6720
- )
6721
-
6722
- expect(transaction.escrow_status).to be_nil
6723
-
6724
- expect do
6725
- Braintree::Transaction.release_from_escrow!(transaction.id)
6726
- end.to raise_error(Braintree::ValidationsFailed)
6727
- end
6728
- end
6729
-
6730
- describe "self.cancel_release" do
6731
- it "returns the transaction if successful" do
6732
- transaction = create_escrowed_transcation
6733
- result = Braintree::Transaction.release_from_escrow(transaction.id)
6734
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
6735
-
6736
- result = Braintree::Transaction.cancel_release(transaction.id)
6737
-
6738
- expect(result.success?).to be(true)
6739
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::Held)
6740
- end
6741
-
6742
- it "returns an error result if escrow_status is not ReleasePending" do
6743
- transaction = create_escrowed_transcation
6744
-
6745
- result = Braintree::Transaction.cancel_release(transaction.id)
6746
-
6747
- expect(result.success?).to be(false)
6748
- expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotCancelRelease)
6749
- end
6750
- end
6751
-
6752
- describe "self.cancel_release!" do
6753
- it "returns the transaction when release is cancelled" do
6754
- transaction = create_escrowed_transcation
6755
- result = Braintree::Transaction.release_from_escrow(transaction.id)
6756
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::ReleasePending)
6757
-
6758
- transaction = Braintree::Transaction.cancel_release!(transaction.id)
6759
-
6760
- expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::Held)
6761
- end
6762
-
6763
- it "raises an error when release cannot be cancelled" do
6764
- transaction = create_escrowed_transcation
6765
-
6766
- expect {
6767
- transaction = Braintree::Transaction.cancel_release!(transaction.id)
6768
- }.to raise_error(Braintree::ValidationsFailed)
6769
- end
6770
- end
6771
-
6772
6727
  describe "self.credit" do
6773
6728
  it "returns a successful result with type=credit if successful" do
6774
6729
  result = Braintree::Transaction.credit(
@@ -6922,6 +6877,34 @@ describe Braintree::Transaction do
6922
6877
  expect(transaction.acquirer_reference_number).to eq("123456789 091019")
6923
6878
  end
6924
6879
 
6880
+ it "finds a transaction and returns a payment_account_reference if the transaction has one" do
6881
+ transaction = Braintree::Transaction.find("aft_txn")
6882
+
6883
+ expect(transaction.credit_card_details).not_to be_nil
6884
+ expect(transaction.credit_card_details).to respond_to(:payment_account_reference)
6885
+ end
6886
+
6887
+ it "finds a transaction and returns a payment_account_reference in apple_pay_details if the transaction has one" do
6888
+ transaction = Braintree::Transaction.find("apple_pay_transaction")
6889
+
6890
+ expect(transaction.apple_pay_details).not_to be_nil
6891
+ expect(transaction.apple_pay_details).to respond_to(:payment_account_reference)
6892
+ end
6893
+
6894
+ it "finds a transaction and returns a payment_account_reference in google_pay_details if the transaction has one" do
6895
+ transaction = Braintree::Transaction.find("android_pay_card_transaction")
6896
+
6897
+ expect(transaction.google_pay_details).not_to be_nil
6898
+ expect(transaction.google_pay_details).to respond_to(:payment_account_reference)
6899
+ end
6900
+
6901
+ it "finds a transaction and returns a payment_account_reference in google_pay_details for network token if the transaction has one" do
6902
+ transaction = Braintree::Transaction.find("android_pay_network_token_transaction")
6903
+
6904
+ expect(transaction.google_pay_details).not_to be_nil
6905
+ expect(transaction.google_pay_details).to respond_to(:payment_account_reference)
6906
+ end
6907
+
6925
6908
  context "disbursement_details" do
6926
6909
  it "includes disbursement_details on found transactions" do
6927
6910
  found_transaction = Braintree::Transaction.find("deposittransaction")
@@ -7054,76 +7037,6 @@ describe Braintree::Transaction do
7054
7037
  end
7055
7038
  end
7056
7039
 
7057
- describe "self.hold_in_escrow" do
7058
- it "returns the transaction if successful" do
7059
- result = Braintree::Transaction.create(
7060
- :type => "sale",
7061
- :amount => Braintree::Test::TransactionAmounts::Authorize,
7062
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
7063
- :credit_card => {
7064
- :number => Braintree::Test::CreditCardNumbers::Visa,
7065
- :expiration_date => "12/12",
7066
- },
7067
- :service_fee_amount => "10.00",
7068
- )
7069
-
7070
- expect(result.transaction.escrow_status).to be_nil
7071
- result = Braintree::Transaction.hold_in_escrow(result.transaction.id)
7072
-
7073
- expect(result.success?).to be(true)
7074
- expect(result.transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
7075
- end
7076
-
7077
- it "returns an error result if the transaction cannot be held in escrow" do
7078
- transaction = Braintree::Transaction.sale!(
7079
- :amount => Braintree::Test::TransactionAmounts::Authorize,
7080
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
7081
- :credit_card => {
7082
- :number => Braintree::Test::CreditCardNumbers::Visa,
7083
- :expiration_date => "05/2009"
7084
- },
7085
- )
7086
-
7087
- result = Braintree::Transaction.hold_in_escrow(transaction.id)
7088
- expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotHoldInEscrow)
7089
- end
7090
- end
7091
-
7092
- describe "self.hold_in_escrow!" do
7093
- it "returns the transaction if successful" do
7094
- result = Braintree::Transaction.create(
7095
- :type => "sale",
7096
- :amount => Braintree::Test::TransactionAmounts::Authorize,
7097
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
7098
- :credit_card => {
7099
- :number => Braintree::Test::CreditCardNumbers::Visa,
7100
- :expiration_date => "12/12",
7101
- },
7102
- :service_fee_amount => "10.00",
7103
- )
7104
-
7105
- expect(result.transaction.escrow_status).to be_nil
7106
- transaction = Braintree::Transaction.hold_in_escrow!(result.transaction.id)
7107
-
7108
- expect(transaction.escrow_status).to eq(Braintree::Transaction::EscrowStatus::HoldPending)
7109
- end
7110
-
7111
- it "raises an error if the transaction cannot be held in escrow" do
7112
- transaction = Braintree::Transaction.sale!(
7113
- :amount => Braintree::Test::TransactionAmounts::Authorize,
7114
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
7115
- :credit_card => {
7116
- :number => Braintree::Test::CreditCardNumbers::Visa,
7117
- :expiration_date => "05/2009"
7118
- },
7119
- )
7120
-
7121
- expect do
7122
- Braintree::Transaction.hold_in_escrow!(transaction.id)
7123
- end.to raise_error(Braintree::ValidationsFailed)
7124
- end
7125
- end
7126
-
7127
7040
  describe "self.void" do
7128
7041
  it "returns a successful result if successful" do
7129
7042
  transaction = Braintree::Transaction.sale!(
@@ -7139,6 +7052,18 @@ describe Braintree::Transaction do
7139
7052
  expect(result.transaction.status).to eq(Braintree::Transaction::Status::Voided)
7140
7053
  end
7141
7054
 
7055
+ it "returns a successful result if contact details passed in" do
7056
+ result = Braintree::Transaction.sale(
7057
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
7058
+ :amount => "10",
7059
+ :options => {
7060
+ :paypal => {}
7061
+ },
7062
+ )
7063
+ expect(result.success?).to eq(true)
7064
+ expect(result.transaction.paypal_details.recipient_email).to eq("test@paypal.com")
7065
+ end
7066
+
7142
7067
  it "returns an error result if unsuccessful" do
7143
7068
  transaction = Braintree::Transaction.sale(
7144
7069
  :amount => Braintree::Test::TransactionAmounts::Decline,
@@ -7321,24 +7246,6 @@ describe Braintree::Transaction do
7321
7246
  Braintree::Transaction.find(transaction.id)
7322
7247
  end
7323
7248
 
7324
- def create_escrowed_transcation
7325
- transaction = Braintree::Transaction.sale!(
7326
- :amount => Braintree::Test::TransactionAmounts::Authorize,
7327
- :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
7328
- :credit_card => {
7329
- :number => Braintree::Test::CreditCardNumbers::Visa,
7330
- :expiration_date => "05/2009"
7331
- },
7332
- :service_fee_amount => "1.00",
7333
- :options => {:hold_in_escrow => true},
7334
- )
7335
-
7336
- config = Braintree::Configuration.instantiate
7337
- config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
7338
- config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/escrow")
7339
- Braintree::Transaction.find(transaction.id)
7340
- end
7341
-
7342
7249
  context "paypal" do
7343
7250
  it "can create a transaction for a paypal account" do
7344
7251
  result = Braintree::Transaction.sale(
@@ -7868,7 +7775,7 @@ describe Braintree::Transaction do
7868
7775
 
7869
7776
  expect(adjustment_transaction.success?).to eq(false)
7870
7777
  expect(adjustment_transaction.transaction.amount).to eq(BigDecimal("75.50"))
7871
- expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AdjustmentAmountMustBeGreaterThanZero)
7778
+ expect(adjustment_transaction.errors.for(:transaction).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AmountMustBeGreaterThanZero)
7872
7779
  end
7873
7780
 
7874
7781
  it "returns failure response, when adjusted amount submitted same as authorized amount" do
@@ -7969,4 +7876,13 @@ describe Braintree::Transaction do
7969
7876
  expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
7970
7877
  end
7971
7878
  end
7879
+
7880
+ describe "upcoming_retry_date" do
7881
+ it "returns the upcoming retry date for ACH transactions" do
7882
+ transaction = Braintree::Transaction.find("first_attempted_ach_transaction")
7883
+
7884
+ tomorrow = Date.today + 1
7885
+ expect(transaction.upcoming_retry_date).to eq(tomorrow.to_s)
7886
+ end
7887
+ end
7972
7888
  end