braintree 2.104.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -23
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +11 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/base_module.rb +6 -0
  11. data/lib/braintree/bin_data.rb +9 -2
  12. data/lib/braintree/client_token.rb +1 -1
  13. data/lib/braintree/configuration.rb +12 -12
  14. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  15. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  16. data/lib/braintree/credit_card.rb +2 -77
  17. data/lib/braintree/credit_card_gateway.rb +17 -36
  18. data/lib/braintree/credit_card_verification.rb +18 -5
  19. data/lib/braintree/credit_card_verification_search.rb +1 -1
  20. data/lib/braintree/customer.rb +9 -78
  21. data/lib/braintree/customer_gateway.rb +2 -23
  22. data/lib/braintree/customer_search.rb +1 -1
  23. data/lib/braintree/disbursement.rb +1 -1
  24. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  25. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  26. data/lib/braintree/dispute.rb +32 -8
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +6 -3
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/enriched_customer_data.rb +21 -0
  31. data/lib/braintree/error_codes.rb +150 -171
  32. data/lib/braintree/exceptions.rb +5 -3
  33. data/lib/braintree/exchange_rate.rb +13 -0
  34. data/lib/braintree/exchange_rate_quote.rb +24 -0
  35. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  36. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  37. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  38. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  39. data/lib/braintree/gateway.rb +4 -14
  40. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
  41. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  42. data/lib/braintree/graphql_client.rb +7 -7
  43. data/lib/braintree/http.rb +4 -3
  44. data/lib/braintree/local_payment_completed.rb +2 -2
  45. data/lib/braintree/local_payment_expired.rb +21 -0
  46. data/lib/braintree/local_payment_funded.rb +22 -0
  47. data/lib/braintree/local_payment_reversed.rb +19 -0
  48. data/lib/braintree/merchant.rb +1 -1
  49. data/lib/braintree/merchant_account.rb +1 -1
  50. data/lib/braintree/merchant_account_gateway.rb +3 -1
  51. data/lib/braintree/merchant_gateway.rb +1 -1
  52. data/lib/braintree/modification.rb +1 -1
  53. data/lib/braintree/oauth_credentials.rb +1 -1
  54. data/lib/braintree/oauth_gateway.rb +5 -5
  55. data/lib/braintree/payment_instrument_type.rb +10 -14
  56. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  57. data/lib/braintree/payment_method_gateway.rb +15 -17
  58. data/lib/braintree/payment_method_nonce.rb +7 -4
  59. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  60. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  61. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  62. data/lib/braintree/payment_method_parser.rb +1 -8
  63. data/lib/braintree/plan.rb +21 -1
  64. data/lib/braintree/plan_gateway.rb +100 -0
  65. data/lib/braintree/processor_response_types.rb +3 -3
  66. data/lib/braintree/resource_collection.rb +8 -3
  67. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  68. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  69. data/lib/braintree/risk_data.rb +5 -1
  70. data/lib/braintree/samsung_pay_card.rb +1 -1
  71. data/lib/braintree/settlement_batch_summary.rb +2 -2
  72. data/lib/braintree/subscription.rb +11 -11
  73. data/lib/braintree/successful_result.rb +3 -2
  74. data/lib/braintree/test/credit_card.rb +1 -0
  75. data/lib/braintree/test/nonce.rb +4 -23
  76. data/lib/braintree/three_d_secure_info.rb +22 -12
  77. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  78. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  79. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  80. data/lib/braintree/transaction/installment.rb +28 -0
  81. data/lib/braintree/transaction/paypal_details.rb +3 -0
  82. data/lib/braintree/transaction/subscription_details.rb +2 -0
  83. data/lib/braintree/transaction.rb +65 -120
  84. data/lib/braintree/transaction_gateway.rb +39 -27
  85. data/lib/braintree/transaction_line_item.rb +1 -1
  86. data/lib/braintree/transaction_review.rb +18 -0
  87. data/lib/braintree/transaction_search.rb +5 -3
  88. data/lib/braintree/unknown_payment_method.rb +1 -1
  89. data/lib/braintree/us_bank_account.rb +3 -3
  90. data/lib/braintree/us_bank_account_verification.rb +1 -1
  91. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  92. data/lib/braintree/util.rb +21 -6
  93. data/lib/braintree/venmo_account.rb +1 -1
  94. data/lib/braintree/venmo_profile_data.rb +23 -0
  95. data/lib/braintree/version.rb +2 -2
  96. data/lib/braintree/visa_checkout_card.rb +2 -2
  97. data/lib/braintree/webhook_notification.rb +44 -30
  98. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  99. data/lib/braintree/webhook_testing_gateway.rb +104 -43
  100. data/lib/braintree/xml/generator.rb +5 -4
  101. data/lib/braintree/xml/parser.rb +22 -35
  102. data/lib/braintree/xml/rexml.rb +4 -5
  103. data/lib/braintree.rb +28 -23
  104. data/spec/integration/braintree/add_on_spec.rb +1 -1
  105. data/spec/integration/braintree/address_spec.rb +30 -113
  106. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  107. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  108. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  109. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  110. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  111. data/spec/integration/braintree/credit_card_spec.rb +219 -593
  112. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  113. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  114. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  115. data/spec/integration/braintree/customer_spec.rb +484 -513
  116. data/spec/integration/braintree/dispute_search_spec.rb +35 -6
  117. data/spec/integration/braintree/dispute_spec.rb +6 -7
  118. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  119. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  120. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  121. data/spec/integration/braintree/http_spec.rb +2 -2
  122. data/spec/integration/braintree/merchant_account_spec.rb +28 -29
  123. data/spec/integration/braintree/merchant_spec.rb +14 -14
  124. data/spec/integration/braintree/oauth_spec.rb +11 -11
  125. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
  126. data/spec/integration/braintree/payment_method_spec.rb +535 -270
  127. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  128. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  129. data/spec/integration/braintree/plan_spec.rb +82 -0
  130. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  131. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  132. data/spec/integration/braintree/subscription_spec.rb +144 -149
  133. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  134. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  135. data/spec/integration/braintree/transaction_search_spec.rb +175 -70
  136. data/spec/integration/braintree/transaction_spec.rb +955 -894
  137. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  138. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  139. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  140. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  141. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  142. data/spec/integration/spec_helper.rb +16 -7
  143. data/spec/oauth_test_helper.rb +1 -1
  144. data/spec/script/httpsd.rb +6 -6
  145. data/spec/spec_helper.rb +8 -14
  146. data/spec/unit/braintree/address_spec.rb +1 -9
  147. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
  148. data/spec/unit/braintree/client_token_spec.rb +2 -2
  149. data/spec/unit/braintree/configuration_spec.rb +42 -42
  150. data/spec/unit/braintree/credit_card_spec.rb +13 -32
  151. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  152. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  153. data/spec/unit/braintree/customer_spec.rb +21 -22
  154. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  155. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  156. data/spec/unit/braintree/dispute_spec.rb +75 -21
  157. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  158. data/spec/unit/braintree/error_result_spec.rb +5 -5
  159. data/spec/unit/braintree/errors_spec.rb +8 -8
  160. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  161. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  162. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  163. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  164. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  165. data/spec/unit/braintree/http_spec.rb +10 -8
  166. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  167. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  168. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  169. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  170. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  171. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  172. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  173. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  174. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  175. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  176. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  177. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  178. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  179. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  180. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  181. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  182. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  183. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  184. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  185. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  186. data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
  187. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  188. data/spec/unit/braintree/transaction_spec.rb +36 -54
  189. data/spec/unit/braintree/util_spec.rb +55 -21
  190. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  191. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  192. data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
  193. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  194. data/spec/unit/braintree/xml_spec.rb +31 -31
  195. metadata +62 -30
  196. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  197. data/lib/braintree/coinbase_account.rb +0 -34
  198. data/lib/braintree/europe_bank_account.rb +0 -36
  199. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  200. data/lib/braintree/ideal_payment.rb +0 -61
  201. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  202. data/lib/braintree/masterpass_card.rb +0 -83
  203. data/lib/braintree/settlement_batch.rb +0 -0
  204. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  205. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  206. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  207. data/lib/braintree/transparent_redirect.rb +0 -40
  208. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  209. data/spec/hacks/tcp_socket.rb +0 -18
  210. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  211. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  212. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  213. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -32,5 +32,19 @@ describe Braintree::LocalPaymentCompleted do
32
32
  local_payment_completed.transaction.order_id.should eq("an-order-id")
33
33
  local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
34
34
  end
35
+
36
+ it "initializes the object with the appropriate attributes set if no transaction is provided" do
37
+ params = {
38
+ payment_id: "a-payment-id",
39
+ payer_id: "a-payer-id",
40
+ payment_method_nonce: "a-nonce",
41
+ }
42
+ local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
43
+
44
+ local_payment_completed.payment_id.should eq("a-payment-id")
45
+ local_payment_completed.payer_id.should eq("a-payer-id")
46
+ local_payment_completed.payment_method_nonce.should eq("a-nonce")
47
+ local_payment_completed.transaction.should be_nil
48
+ end
35
49
  end
36
50
  end
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::LocalPaymentExpired do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::LocalPaymentExpired.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+ params = {
15
+ payment_id: "a-payment-id",
16
+ payment_context_id: "a-payment-context-id",
17
+ }
18
+ local_payment_expired = Braintree::LocalPaymentExpired._new(params)
19
+
20
+ local_payment_expired.payment_id.should eq("a-payment-id")
21
+ local_payment_expired.payment_context_id.should eq("a-payment-context-id")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::LocalPaymentFunded do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::LocalPaymentFunded.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+ params = {
15
+ payment_id: "a-payment-id",
16
+ payment_context_id: "a-payment-context-id",
17
+ transaction: {
18
+ id: "a-transaction-id",
19
+ amount: "31.00",
20
+ order_id: "an-order-id",
21
+ status: Braintree::Transaction::Status::Settled,
22
+ },
23
+ }
24
+ local_payment_funded = Braintree::LocalPaymentFunded._new(params)
25
+
26
+ local_payment_funded.payment_id.should eq("a-payment-id")
27
+ local_payment_funded.payment_context_id.should eq("a-payment-context-id")
28
+ local_payment_funded.transaction.id.should eq("a-transaction-id")
29
+ local_payment_funded.transaction.amount.should eq(31.0)
30
+ local_payment_funded.transaction.order_id.should eq("an-order-id")
31
+ local_payment_funded.transaction.status.should eq(Braintree::Transaction::Status::Settled)
32
+ end
33
+ end
34
+ end
@@ -13,7 +13,7 @@ describe Braintree::MerchantAccount do
13
13
  nil,
14
14
  :id => "merchant_account",
15
15
  :status => "active",
16
- :master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil}
16
+ :master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil},
17
17
  )
18
18
 
19
19
  master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::PaymentMethodCustomerDataUpdatedMetadata.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+
15
+ params = {
16
+ token: "a-token",
17
+ payment_method: {
18
+ venmo_account: {
19
+ venmo_user_id: "venmo-user-id",
20
+ },
21
+ },
22
+ datetime_updated: "2022-01-01T21:28:37Z",
23
+ enriched_customer_data: {
24
+ fields_updated: ["username"],
25
+ profile_data: {
26
+ username: "a-username",
27
+ first_name: "a-first-name",
28
+ last_name: "a-last-name",
29
+ phone_number: "a-phone-number",
30
+ email: "a-email",
31
+ },
32
+ },
33
+ }
34
+
35
+ payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
36
+
37
+ payment_method_customer_data_updated.token.should eq("a-token")
38
+ payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
39
+ payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
40
+ payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
41
+ payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
42
+ payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodNonceDetailsPayerInfo do
4
+ let(:payment_method_nonce_details_payer_info) {
5
+ Braintree::PaymentMethodNonceDetailsPayerInfo.new(
6
+ :billing_agreement_id => "billing-agreement-id",
7
+ :country_code => "US",
8
+ :email => "test@example.com",
9
+ :first_name => "First",
10
+ :last_name => "Last",
11
+ :payer_id => "payer-id",
12
+ )
13
+ }
14
+
15
+ describe "#initialize" do
16
+ it "sets attributes" do
17
+ payment_method_nonce_details_payer_info.billing_agreement_id.should == "billing-agreement-id"
18
+ payment_method_nonce_details_payer_info.country_code.should == "US"
19
+ payment_method_nonce_details_payer_info.email.should == "test@example.com"
20
+ payment_method_nonce_details_payer_info.first_name.should == "First"
21
+ payment_method_nonce_details_payer_info.last_name.should == "Last"
22
+ payment_method_nonce_details_payer_info.payer_id.should == "payer-id"
23
+ end
24
+ end
25
+
26
+ describe "inspect" do
27
+ it "prints the attributes" do
28
+ payment_method_nonce_details_payer_info.inspect.should == %(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,43 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodNonceDetails do
4
+ let(:payment_method_nonce_details) {
5
+ Braintree::PaymentMethodNonceDetails.new(
6
+ :bin => "bin",
7
+ :card_type => "American Express",
8
+ :expiration_month => "12",
9
+ :expiration_year => "2025",
10
+ :is_network_tokenized => true,
11
+ :last_two => "11",
12
+ :payer_info => {
13
+ :billing_agreement_id => "1234",
14
+ :country_code => "US",
15
+ },
16
+ )
17
+ }
18
+
19
+ describe "#initialize" do
20
+ it "sets attributes" do
21
+ payment_method_nonce_details.bin.should == "bin"
22
+ payment_method_nonce_details.card_type.should == "American Express"
23
+ payment_method_nonce_details.expiration_month.should == "12"
24
+ payment_method_nonce_details.expiration_year.should == "2025"
25
+ payment_method_nonce_details.is_network_tokenized.should == true
26
+ payment_method_nonce_details.last_two.should == "11"
27
+ payment_method_nonce_details.payer_info.billing_agreement_id.should == "1234"
28
+ payment_method_nonce_details.payer_info.country_code.should == "US"
29
+ end
30
+ end
31
+
32
+ describe "inspect" do
33
+ it "prints the attributes" do
34
+ payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>>)
35
+ end
36
+ end
37
+
38
+ describe "is_network_tokenized" do
39
+ it "is aliased to is_network_tokenized?" do
40
+ payment_method_nonce_details.is_network_tokenized?.should == true
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodNonce do
4
+ let(:payment_method_nonce) {
5
+ Braintree::PaymentMethodNonce._new(
6
+ :gateway,
7
+ :nonce => "some-nonce",
8
+ :type => "CreditCard",
9
+ :default => true,
10
+ :details => {
11
+ :bin => "some-bin"
12
+ },
13
+ :three_d_secure_info => {
14
+ :liability_shift_possible => false,
15
+ :liability_shifted => false
16
+ },
17
+ :bin_data => {
18
+ :country_of_issuance => "USA"
19
+ },
20
+ )
21
+ }
22
+
23
+ describe "#initialize" do
24
+ it "sets attributes" do
25
+ expect(payment_method_nonce.nonce).to eq("some-nonce")
26
+ expect(payment_method_nonce.type).to eq("CreditCard")
27
+ expect(payment_method_nonce.default).to be true
28
+ expect(payment_method_nonce.details.bin).to eq("some-bin")
29
+ expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
30
+ expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
31
+ expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
32
+ end
33
+ end
34
+
35
+ describe "default" do
36
+ it "is aliased to default?" do
37
+ expect(payment_method_nonce.default?).to be true
38
+ end
39
+ end
40
+ end
@@ -28,7 +28,7 @@ describe Braintree::PaymentMethod do
28
28
  end
29
29
 
30
30
  describe "delete" do
31
- let(:http_stub) { double('http_stub').as_null_object }
31
+ let(:http_stub) { double("http_stub").as_null_object }
32
32
  it "accepts revoke_all_grants option with value true" do
33
33
  Braintree::Http.stub(:new).and_return http_stub
34
34
  http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
@@ -8,7 +8,7 @@ describe Braintree::PayPalAccount do
8
8
  :invalid_key => "bad stuff",
9
9
  :options => {
10
10
  :invalid_option => "bad option",
11
- }
11
+ },
12
12
  )
13
13
  end.to raise_error(ArgumentError, "invalid keys: invalid_key, options[invalid_option]")
14
14
  end
@@ -17,7 +17,7 @@ describe Braintree::PayPalAccount do
17
17
  describe "self.update" do
18
18
  it "raises an exception if attributes contain an invalid key" do
19
19
  expect do
20
- Braintree::PayPalAccount.update("some_token", :invalid_key => 'val')
20
+ Braintree::PayPalAccount.update("some_token", :invalid_key => "val")
21
21
  end.to raise_error(ArgumentError, "invalid keys: invalid_key")
22
22
  end
23
23
  end
@@ -5,7 +5,7 @@ describe "Braintree::ResourceCollection" do
5
5
  it "iterates over the elements, yielding to the block in pages" do
6
6
  values = %w(a b c d e)
7
7
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
8
- ids.map {|id| values[id] }
8
+ ids.map { |id| values[id] }
9
9
  end
10
10
 
11
11
  count = 0
@@ -18,6 +18,35 @@ describe "Braintree::ResourceCollection" do
18
18
  end
19
19
  end
20
20
 
21
+ describe "#first" do
22
+ it "returns nil with no results" do
23
+ values = %w(a b c d e)
24
+ collection = Braintree::ResourceCollection.new(:search_results => {:ids => [], :page_size => 2}) do |ids|
25
+ ids.map { |id| values[id] }
26
+ end
27
+
28
+ collection.first.should == nil
29
+ end
30
+
31
+ context "with results" do
32
+ let(:collection) do
33
+ values = %w(a b c d e)
34
+
35
+ Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
36
+ ids.map { |id| values[id] }
37
+ end
38
+ end
39
+
40
+ it "returns the first occourence" do
41
+ collection.first.should == "a"
42
+ end
43
+
44
+ it "returns the first N occourences" do
45
+ collection.first(4).should == ["a","b","c","d"]
46
+ end
47
+ end
48
+ end
49
+
21
50
  describe "#ids" do
22
51
  it "returns a list of the resource collection ids" do
23
52
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::LiabilityShift do
4
+ describe "#initialize" do
5
+ it "sets responsible party and conditions" do
6
+ liability_shift = Braintree::Transaction::LiabilityShift.new(
7
+ :responsible_party => "paypal",
8
+ :conditions => ["unauthorized","item_not_received"],
9
+ )
10
+
11
+ expect(liability_shift.responsible_party).to eql "paypal"
12
+ expect(liability_shift.conditions.first).to eql "unauthorized"
13
+ end
14
+ end
15
+
16
+ describe "inspect" do
17
+ it "prints the attributes" do
18
+ details = Braintree::Transaction::LiabilityShift.new(
19
+ :responsible_party => "paypal",
20
+ :conditions => ["unauthorized","item_not_received"],
21
+ )
22
+
23
+ expect(details.inspect).to eql %(#<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized", "item_not_received"]>)
24
+ end
25
+ end
26
+ end
@@ -2,12 +2,31 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Braintree::RiskData do
4
4
  describe "#initialize" do
5
- it "sets id, decision and device_data_captured" do
6
- risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "kount")
7
- risk_data.id.should == "123"
8
- risk_data.decision.should == "YOU WON $1000 DOLLARS"
9
- risk_data.device_data_captured.should be_truthy
10
- risk_data.fraud_service_provider.should == "kount"
5
+ it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
6
+ risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
7
+ expect(risk_data.id).to eql "123"
8
+ expect(risk_data.decision).to eql "YOU WON $1000 DOLLARS"
9
+ expect(risk_data.device_data_captured).to be_truthy
10
+ expect(risk_data.fraud_service_provider).to eql "fraud_protection"
11
+ expect(risk_data.decision_reasons).to eql ["reason"]
12
+ expect(risk_data.transaction_risk_score).to eql "12"
13
+ expect(risk_data.liability_shift).to be_nil
14
+ end
15
+
16
+ it "sets liability shift info" do
17
+ risk_data = Braintree::RiskData.new(
18
+ :id => "123",
19
+ :decision => "YOU WON $1000 DOLLARS",
20
+ :device_data_captured => true,
21
+ :fraud_service_provider => "fraud_protection",
22
+ :decision_reasons => ["reason"],
23
+ :transaction_risk_score => "12",
24
+ :liability_shift => {
25
+ :responsible_party => "paypal",
26
+ :conditions => ["unauthorized"]},
27
+ )
28
+ expect(risk_data.liability_shift.responsible_party).to eql "paypal"
29
+ expect(risk_data.liability_shift.conditions).to eql ["unauthorized"]
11
30
  end
12
31
  end
13
32
 
@@ -16,10 +35,21 @@ describe Braintree::RiskData do
16
35
  details = Braintree::RiskData.new(
17
36
  :id => "123",
18
37
  :decision => "YOU WON $1000 DOLLARS",
38
+ :decision_reasons => ["reason"],
19
39
  :device_data_captured => true,
20
- :fraud_service_provider => "kount",
40
+ :fraud_service_provider => "fraud_protection",
41
+ :transaction_risk_score => "12",
42
+ )
43
+ expect(details.inspect).to eql %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", liability_shift: nil, transaction_risk_score: "12">)
44
+ end
45
+
46
+ it "prints liability shift attributes, too" do
47
+ details = Braintree::RiskData.new(
48
+ :liability_shift => {
49
+ :responsible_party => "paypal",
50
+ :conditions => ["unauthorized"]},
21
51
  )
22
- details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", device_data_captured: true, fraud_service_provider: "kount">)
52
+ expect(details.inspect).to eql %(#<RiskData id: nil, decision: nil, decision_reasons: nil, device_data_captured: nil, fraud_service_provider: nil, liability_shift: #<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized"]>, transaction_risk_score: nil>)
23
53
  end
24
54
  end
25
55
  end
@@ -11,7 +11,7 @@ module Braintree
11
11
  Subscription::Status::Active,
12
12
  Subscription::Status::Canceled,
13
13
  Subscription::Status::Expired,
14
- Subscription::Status::PastDue
14
+ Subscription::Status::PastDue,
15
15
  )
16
16
  end.should_not raise_error
17
17
  end
@@ -5,7 +5,7 @@ describe Braintree::SuccessfulResult do
5
5
  it "sets instance variables from the values in the hash" do
6
6
  result = Braintree::SuccessfulResult.new(
7
7
  :transaction => "transaction_value",
8
- :credit_card => "credit_card_value"
8
+ :credit_card => "credit_card_value",
9
9
  )
10
10
  result.success?.should == true
11
11
  result.transaction.should == "transaction_value"
@@ -3,37 +3,55 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
3
3
  describe Braintree::ThreeDSecureInfo do
4
4
  let(:three_d_secure_info) {
5
5
  Braintree::ThreeDSecureInfo.new(
6
+ :acs_transaction_id => "acs_id",
7
+ :cavv => "cavvvalue",
8
+ :ds_transaction_id => "dstrxid",
9
+ :eci_flag => "06",
6
10
  :enrolled => "Y",
7
- :liability_shifted => true,
8
11
  :liability_shift_possible => true,
9
- :cavv => "cavvvalue",
10
- :xid => "xidvalue",
12
+ :liability_shifted => true,
13
+ :pares_status => "Y",
11
14
  :status => "authenticate_successful",
12
- :eci_flag => "06",
13
- :three_d_secure_version => "1.0.2",
14
- :ds_transaction_id => "dstrxid",
15
15
  :three_d_secure_authentication_id => "auth_id",
16
+ :three_d_secure_transaction_id => "trans_id",
17
+ :three_d_secure_version => "1.0.2",
18
+ :xid => "xidvalue",
19
+ :authentication => {
20
+ :trans_status => "authstatus",
21
+ :trans_status_reason => "authstatusreason"
22
+ },
23
+ :lookup => {
24
+ :trans_status => "lookupstatus",
25
+ :trans_status_reason => "lookupstatusreason"
26
+ },
16
27
  )
17
28
  }
18
29
 
19
30
  describe "#initialize" do
20
31
  it "sets attributes" do
21
- three_d_secure_info.enrolled.should == "Y"
22
- three_d_secure_info.status.should == "authenticate_successful"
23
- three_d_secure_info.liability_shifted.should == true
24
- three_d_secure_info.liability_shift_possible.should == true
32
+ three_d_secure_info.acs_transaction_id.should == "acs_id"
25
33
  three_d_secure_info.cavv.should == "cavvvalue"
26
- three_d_secure_info.xid.should == "xidvalue"
27
- three_d_secure_info.eci_flag.should == "06"
28
- three_d_secure_info.three_d_secure_version.should == "1.0.2"
29
34
  three_d_secure_info.ds_transaction_id.should == "dstrxid"
35
+ three_d_secure_info.eci_flag.should == "06"
36
+ three_d_secure_info.enrolled.should == "Y"
37
+ three_d_secure_info.liability_shift_possible.should == true
38
+ three_d_secure_info.liability_shifted.should == true
39
+ three_d_secure_info.pares_status.should == "Y"
40
+ three_d_secure_info.status.should == "authenticate_successful"
30
41
  three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
42
+ three_d_secure_info.three_d_secure_transaction_id.should == "trans_id"
43
+ three_d_secure_info.three_d_secure_version.should == "1.0.2"
44
+ three_d_secure_info.xid.should == "xidvalue"
45
+ three_d_secure_info.lookup[:trans_status].should == "lookupstatus"
46
+ three_d_secure_info.lookup[:trans_status_reason].should == "lookupstatusreason"
47
+ three_d_secure_info.authentication[:trans_status].should == "authstatus"
48
+ three_d_secure_info.authentication[:trans_status_reason].should == "authstatusreason"
31
49
  end
32
50
  end
33
51
 
34
52
  describe "inspect" do
35
53
  it "prints the attributes" do
36
- three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y", liability_shifted: true, liability_shift_possible: true, status: "authenticate_successful", cavv: "cavvvalue", xid: "xidvalue", eci_flag: "06", three_d_secure_version: "1.0.2", ds_transaction_id: "dstrxid", three_d_secure_authentication_id: "auth_id">)
54
+ three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">)
37
55
  end
38
56
  end
39
57
 
@@ -5,7 +5,7 @@ describe Braintree::Transaction::CreditCardDetails do
5
5
  it "concats expiration_month and expiration_year" do
6
6
  details = Braintree::Transaction::CreditCardDetails.new(
7
7
  :expiration_month => "08",
8
- :expiration_year => "2009"
8
+ :expiration_year => "2009",
9
9
  )
10
10
  details.expiration_date.should == "08/2009"
11
11
  end
@@ -32,7 +32,7 @@ describe Braintree::Transaction::CreditCardDetails do
32
32
  :country_of_issuance => "Lilliput",
33
33
  :issuing_bank => "Gulliver Bank",
34
34
  :image_url => "example.com/visa.png",
35
- :unique_number_identifier => "abc123"
35
+ :unique_number_identifier => "abc123",
36
36
  )
37
37
  details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", product_id: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank", image_url: "example.com/visa.png", unique_number_identifier: "abc123">)
38
38
  end
@@ -41,7 +41,7 @@ describe Braintree::Transaction::CreditCardDetails do
41
41
  describe "masked_number" do
42
42
  it "concatenates the bin, some *'s, and the last_4" do
43
43
  details = Braintree::Transaction::CreditCardDetails.new(
44
- :bin => "510510", :last_4 => "5100"
44
+ :bin => "510510", :last_4 => "5100",
45
45
  )
46
46
  details.masked_number.should == "510510******5100"
47
47
  end
@@ -11,7 +11,7 @@ describe Braintree::Transaction::CustomerDetails do
11
11
  :company => "Smith Co.",
12
12
  :website => "http://www.example.com",
13
13
  :phone => "6145551234",
14
- :fax => "3125551234"
14
+ :fax => "3125551234",
15
15
  )
16
16
  details.inspect.should == %(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">)
17
17
  end
@@ -4,13 +4,13 @@ describe Braintree::Transaction::DisbursementDetails do
4
4
  describe "valid?" do
5
5
  it "returns true if disbursement details are initialized" do
6
6
  details = Braintree::Transaction::DisbursementDetails.new(
7
- :disbursement_date => Date.new(2013, 4, 1)
7
+ :disbursement_date => Date.new(2013, 4, 1),
8
8
  )
9
9
  details.valid?.should == true
10
10
  end
11
11
  it "returns true if disbursement details are initialized" do
12
12
  details = Braintree::Transaction::DisbursementDetails.new(
13
- :disbursement_date => nil
13
+ :disbursement_date => nil,
14
14
  )
15
15
  details.valid?.should == false
16
16
  end
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::Installment do
4
+ describe "inspect" do
5
+ it "assigns all fields" do
6
+ adjustment_attributes = {
7
+ :amount => "0.98",
8
+ :kind => "REFUND",
9
+ :projected_disbursement_date => "2020-01-03 01:02:03Z",
10
+ :actual_disbursement_date => "2020-01-04 01:02:03Z",
11
+ }
12
+ installment_attributes = {
13
+ :id => "abc123",
14
+ :amount => "1.23",
15
+ :projected_disbursement_date => "2020-01-01 01:02:03Z",
16
+ :actual_disbursement_date => "2020-01-02 01:02:03Z",
17
+ :adjustments => [adjustment_attributes],
18
+ }
19
+
20
+ installment = Braintree::Transaction::Installment.new(installment_attributes)
21
+
22
+ expect(installment.inspect).to eq('#<id: "abc123", amount: 0.123e1, projected_disbursement_date: "2020-01-01 01:02:03Z", actual_disbursement_date: "2020-01-02 01:02:03Z", adjustments: [#<amount: 0.98e0, kind: "REFUND", projected_disbursement_date: "2020-01-03 01:02:03Z", actual_disbursement_date: "2020-01-04 01:02:03Z">]>')
23
+ end
24
+ end
25
+ end
@@ -5,6 +5,7 @@ describe Braintree::Transaction::PayPalDetails do
5
5
  it "sets all fields" do
6
6
  details = Braintree::Transaction::PayPalDetails.new(
7
7
  :authorization_id => "id",
8
+ :billing_agreement_id => "billing-agreement-id",
8
9
  :capture_id => "capture-id",
9
10
  :custom_field => "custom-field",
10
11
  :debug_id => "debug-id",
@@ -24,12 +25,15 @@ describe Braintree::Transaction::PayPalDetails do
24
25
  :refund_from_transaction_fee_currency_iso_code => "123",
25
26
  :refund_id => "refund-id",
26
27
  :seller_protection_status => "seller-protection-status",
28
+ :tax_id => "tax-id",
29
+ :tax_id_type => "tax-id-type",
27
30
  :token => "token",
28
31
  :transaction_fee_amount => "2.00",
29
- :transaction_fee_currency_iso_code => "123"
32
+ :transaction_fee_currency_iso_code => "123",
30
33
  )
31
34
 
32
35
  expect(details.authorization_id).to eq("id")
36
+ expect(details.billing_agreement_id).to eq("billing-agreement-id")
33
37
  expect(details.capture_id).to eq("capture-id")
34
38
  expect(details.custom_field).to eq("custom-field")
35
39
  expect(details.debug_id).to eq("debug-id")
@@ -49,6 +53,8 @@ describe Braintree::Transaction::PayPalDetails do
49
53
  expect(details.refund_from_transaction_fee_currency_iso_code).to eq("123")
50
54
  expect(details.refund_id).to eq("refund-id")
51
55
  expect(details.seller_protection_status).to eq("seller-protection-status")
56
+ expect(details.tax_id).to eq("tax-id")
57
+ expect(details.tax_id_type).to eq("tax-id-type")
52
58
  expect(details.token).to eq("token")
53
59
  expect(details.transaction_fee_amount).to eq("2.00")
54
60
  expect(details.transaction_fee_currency_iso_code).to eq("123")