braintree 4.14.0 → 4.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/credit_card.rb +13 -0
  3. data/lib/braintree/credit_card_gateway.rb +15 -3
  4. data/lib/braintree/payment_method_gateway.rb +15 -3
  5. data/lib/braintree/test/nonce.rb +1 -0
  6. data/lib/braintree/test/venmo_sdk.rb +2 -0
  7. data/lib/braintree/transaction/credit_card_details.rb +3 -0
  8. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  9. data/lib/braintree/transaction.rb +5 -4
  10. data/lib/braintree/transaction_gateway.rb +15 -3
  11. data/lib/braintree/transaction_search.rb +6 -5
  12. data/lib/braintree/version.rb +1 -1
  13. data/lib/braintree/webhook_notification.rb +1 -0
  14. data/lib/braintree/webhook_testing_gateway.rb +17 -0
  15. data/spec/integration/braintree/add_on_spec.rb +9 -9
  16. data/spec/integration/braintree/address_spec.rb +69 -69
  17. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  18. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  19. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  20. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  21. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  22. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  23. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  24. data/spec/integration/braintree/customer_spec.rb +313 -313
  25. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  26. data/spec/integration/braintree/discount_spec.rb +9 -9
  27. data/spec/integration/braintree/dispute_spec.rb +87 -87
  28. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  29. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  30. data/spec/integration/braintree/http_spec.rb +28 -28
  31. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  32. data/spec/integration/braintree/merchant_spec.rb +103 -103
  33. data/spec/integration/braintree/oauth_spec.rb +61 -61
  34. data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
  35. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  36. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
  37. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  38. data/spec/integration/braintree/plan_spec.rb +15 -15
  39. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  40. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  41. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  42. data/spec/integration/braintree/subscription_spec.rb +364 -364
  43. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  44. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  45. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  46. data/spec/integration/braintree/transaction_search_spec.rb +198 -165
  47. data/spec/integration/braintree/transaction_spec.rb +1315 -1149
  48. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  49. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  50. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  51. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  52. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  53. data/spec/spec_helper.rb +9 -8
  54. data/spec/unit/braintree/address_spec.rb +8 -8
  55. data/spec/unit/braintree/base_module_spec.rb +4 -4
  56. data/spec/unit/braintree/client_token_spec.rb +2 -2
  57. data/spec/unit/braintree/configuration_spec.rb +57 -57
  58. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  59. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  60. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  61. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  62. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  63. data/spec/unit/braintree/customer_spec.rb +41 -40
  64. data/spec/unit/braintree/digest_spec.rb +5 -5
  65. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  66. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  67. data/spec/unit/braintree/dispute_spec.rb +56 -56
  68. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  69. data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
  70. data/spec/unit/braintree/error_result_spec.rb +5 -5
  71. data/spec/unit/braintree/errors_spec.rb +9 -9
  72. data/spec/unit/braintree/http_spec.rb +8 -8
  73. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  74. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  75. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  76. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  77. data/spec/unit/braintree/modification_spec.rb +1 -1
  78. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  79. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  80. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  81. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  82. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  83. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  84. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  85. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  86. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  87. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  88. data/spec/unit/braintree/subscription_spec.rb +8 -8
  89. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  90. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  91. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  92. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  93. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  94. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  95. data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
  96. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  97. data/spec/unit/braintree/transaction_spec.rb +101 -93
  98. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  99. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  100. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  101. data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
  102. data/spec/unit/braintree/util_spec.rb +27 -27
  103. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  104. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  105. data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
  106. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  107. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  108. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  109. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  110. data/spec/unit/braintree/xml_spec.rb +17 -17
  111. data/spec/unit/braintree_spec.rb +2 -2
  112. metadata +3 -2
@@ -25,19 +25,19 @@ describe Braintree::SepaDirectDebitAccount do
25
25
  context "when payment method exists" do
26
26
  it "returns a payment method" do
27
27
  sepa_direct_debit_account = subject
28
- sepa_direct_debit_account.should be_a(Braintree::SepaDirectDebitAccount)
29
- sepa_direct_debit_account.last_4.should == "1234"
30
- sepa_direct_debit_account.default.should == true
31
- sepa_direct_debit_account.customer_id.should == customer.id
32
- sepa_direct_debit_account.global_id.should_not be_empty
33
- sepa_direct_debit_account.customer_global_id.should_not be_empty
34
- sepa_direct_debit_account.bank_reference_token.should == "a-fake-bank-reference-token"
35
- sepa_direct_debit_account.mandate_type.should == "RECURRENT"
36
- sepa_direct_debit_account.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
37
- sepa_direct_debit_account.token.should_not be_empty
38
- sepa_direct_debit_account.image_url.should_not be_empty
39
- sepa_direct_debit_account.created_at.should be_a Time
40
- sepa_direct_debit_account.updated_at.should be_a Time
28
+ expect(sepa_direct_debit_account).to be_a(Braintree::SepaDirectDebitAccount)
29
+ expect(sepa_direct_debit_account.last_4).to eq("1234")
30
+ expect(sepa_direct_debit_account.default).to eq(true)
31
+ expect(sepa_direct_debit_account.customer_id).to eq(customer.id)
32
+ expect(sepa_direct_debit_account.global_id).not_to be_empty
33
+ expect(sepa_direct_debit_account.customer_global_id).not_to be_empty
34
+ expect(sepa_direct_debit_account.bank_reference_token).to eq("a-fake-bank-reference-token")
35
+ expect(sepa_direct_debit_account.mandate_type).to eq("RECURRENT")
36
+ expect(sepa_direct_debit_account.merchant_or_partner_customer_id).to eq("a-fake-mp-customer-id")
37
+ expect(sepa_direct_debit_account.token).not_to be_empty
38
+ expect(sepa_direct_debit_account.image_url).not_to be_empty
39
+ expect(sepa_direct_debit_account.created_at).to be_a Time
40
+ expect(sepa_direct_debit_account.updated_at).to be_a Time
41
41
  end
42
42
  end
43
43
 
@@ -79,7 +79,7 @@ describe Braintree::SepaDirectDebitAccount do
79
79
 
80
80
  context "when payment method exists" do
81
81
  it "deletes a payment method" do
82
- should be_success
82
+ is_expected.to be_success
83
83
 
84
84
  expect {
85
85
  described_class.find(token)
@@ -111,28 +111,28 @@ describe Braintree::SepaDirectDebitAccount do
111
111
 
112
112
  context "when payment method exists" do
113
113
  it "creates a transaction" do
114
- should be_success
114
+ is_expected.to be_success
115
115
 
116
116
  transaction = subject.transaction
117
- transaction.amount.should eq(1.23)
118
- transaction.status.should == "settling"
117
+ expect(transaction.amount).to eq(1.23)
118
+ expect(transaction.status).to eq("settling")
119
119
  sepa_direct_debit_account_details = transaction.sepa_direct_debit_account_details
120
- sepa_direct_debit_account_details.should be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
121
- sepa_direct_debit_account_details.bank_reference_token.should == "a-fake-bank-reference-token"
122
- sepa_direct_debit_account_details.capture_id.should_not be_empty
123
- sepa_direct_debit_account_details.debug_id.should be_nil
124
- sepa_direct_debit_account_details.global_id.should_not be_empty
125
- sepa_direct_debit_account_details.last_4.should == "1234"
126
- sepa_direct_debit_account_details.mandate_type.should == "RECURRENT"
127
- sepa_direct_debit_account_details.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
128
- sepa_direct_debit_account_details.paypal_v2_order_id.should be_nil
129
- sepa_direct_debit_account_details.refund_from_transaction_fee_amount.should be_nil
130
- sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.should be_nil
131
- sepa_direct_debit_account_details.refund_id.should be_nil
132
- sepa_direct_debit_account_details.settlement_type.should be_nil
133
- sepa_direct_debit_account_details.token.should == token
134
- sepa_direct_debit_account_details.transaction_fee_amount.should == "0.01"
135
- sepa_direct_debit_account_details.transaction_fee_currency_iso_code.should == "USD"
120
+ expect(sepa_direct_debit_account_details).to be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
121
+ expect(sepa_direct_debit_account_details.bank_reference_token).to eq("a-fake-bank-reference-token")
122
+ expect(sepa_direct_debit_account_details.capture_id).not_to be_empty
123
+ expect(sepa_direct_debit_account_details.debug_id).to be_nil
124
+ expect(sepa_direct_debit_account_details.global_id).not_to be_empty
125
+ expect(sepa_direct_debit_account_details.last_4).to eq("1234")
126
+ expect(sepa_direct_debit_account_details.mandate_type).to eq("RECURRENT")
127
+ expect(sepa_direct_debit_account_details.merchant_or_partner_customer_id).to eq("a-fake-mp-customer-id")
128
+ expect(sepa_direct_debit_account_details.paypal_v2_order_id).to be_nil
129
+ expect(sepa_direct_debit_account_details.refund_from_transaction_fee_amount).to be_nil
130
+ expect(sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code).to be_nil
131
+ expect(sepa_direct_debit_account_details.refund_id).to be_nil
132
+ expect(sepa_direct_debit_account_details.settlement_type).to be_nil
133
+ expect(sepa_direct_debit_account_details.token).to eq(token)
134
+ expect(sepa_direct_debit_account_details.transaction_fee_amount).to eq("0.01")
135
+ expect(sepa_direct_debit_account_details.transaction_fee_currency_iso_code).to eq("USD")
136
136
  end
137
137
  end
138
138
 
@@ -161,25 +161,25 @@ describe Braintree::SepaDirectDebitAccount do
161
161
  context "when payment method exists" do
162
162
  it "creates a transaction" do
163
163
  transaction = subject
164
- transaction.amount.should eq(1.23)
165
- transaction.status.should == "settling"
164
+ expect(transaction.amount).to eq(1.23)
165
+ expect(transaction.status).to eq("settling")
166
166
  sepa_direct_debit_account_details = transaction.sepa_direct_debit_account_details
167
- sepa_direct_debit_account_details.should be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
168
- sepa_direct_debit_account_details.bank_reference_token.should == "a-fake-bank-reference-token"
169
- sepa_direct_debit_account_details.capture_id.should_not be_empty
170
- sepa_direct_debit_account_details.debug_id.should be_nil
171
- sepa_direct_debit_account_details.global_id.should_not be_empty
172
- sepa_direct_debit_account_details.last_4.should == "1234"
173
- sepa_direct_debit_account_details.mandate_type.should == "RECURRENT"
174
- sepa_direct_debit_account_details.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
175
- sepa_direct_debit_account_details.paypal_v2_order_id.should be_nil
176
- sepa_direct_debit_account_details.refund_from_transaction_fee_amount.should be_nil
177
- sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.should be_nil
178
- sepa_direct_debit_account_details.refund_id.should be_nil
179
- sepa_direct_debit_account_details.settlement_type.should be_nil
180
- sepa_direct_debit_account_details.token.should == token
181
- sepa_direct_debit_account_details.transaction_fee_amount.should == "0.01"
182
- sepa_direct_debit_account_details.transaction_fee_currency_iso_code.should == "USD"
167
+ expect(sepa_direct_debit_account_details).to be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
168
+ expect(sepa_direct_debit_account_details.bank_reference_token).to eq("a-fake-bank-reference-token")
169
+ expect(sepa_direct_debit_account_details.capture_id).not_to be_empty
170
+ expect(sepa_direct_debit_account_details.debug_id).to be_nil
171
+ expect(sepa_direct_debit_account_details.global_id).not_to be_empty
172
+ expect(sepa_direct_debit_account_details.last_4).to eq("1234")
173
+ expect(sepa_direct_debit_account_details.mandate_type).to eq("RECURRENT")
174
+ expect(sepa_direct_debit_account_details.merchant_or_partner_customer_id).to eq("a-fake-mp-customer-id")
175
+ expect(sepa_direct_debit_account_details.paypal_v2_order_id).to be_nil
176
+ expect(sepa_direct_debit_account_details.refund_from_transaction_fee_amount).to be_nil
177
+ expect(sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code).to be_nil
178
+ expect(sepa_direct_debit_account_details.refund_id).to be_nil
179
+ expect(sepa_direct_debit_account_details.settlement_type).to be_nil
180
+ expect(sepa_direct_debit_account_details.token).to eq(token)
181
+ expect(sepa_direct_debit_account_details.transaction_fee_amount).to eq("0.01")
182
+ expect(sepa_direct_debit_account_details.transaction_fee_currency_iso_code).to eq("USD")
183
183
  end
184
184
  end
185
185
 
@@ -5,14 +5,14 @@ describe Braintree::SettlementBatchSummary do
5
5
  describe "self.generate" do
6
6
  it "returns an empty collection if there is not data" do
7
7
  result = Braintree::SettlementBatchSummary.generate("1979-01-01")
8
- result.should be_success
9
- result.settlement_batch_summary.records.size.should be_zero
8
+ expect(result).to be_success
9
+ expect(result.settlement_batch_summary.records.size).to be_zero
10
10
  end
11
11
 
12
12
  it "returns an error response if the date cannot be parsed" do
13
13
  result = Braintree::SettlementBatchSummary.generate("NOT A DATE :(")
14
- result.should_not be_success
15
- result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
14
+ expect(result).not_to be_success
15
+ expect(result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }).to include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
16
16
  end
17
17
 
18
18
  it "returns transactions settled on a given day" do
@@ -29,10 +29,10 @@ describe Braintree::SettlementBatchSummary do
29
29
  settlement_date = result[:transaction][:settlement_batch_id].split("_").first
30
30
  result = Braintree::SettlementBatchSummary.generate(settlement_date)
31
31
 
32
- result.should be_success
32
+ expect(result).to be_success
33
33
  amex_records = result.settlement_batch_summary.records.select { |row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
34
- amex_records.first[:count].to_i.should >= 1
35
- amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
34
+ expect(amex_records.first[:count].to_i).to be >= 1
35
+ expect(amex_records.first[:amount_settled].to_i).to be >= Braintree::Test::TransactionAmounts::Authorize.to_i
36
36
  end
37
37
 
38
38
  it "can be grouped by a custom field" do
@@ -52,11 +52,11 @@ describe Braintree::SettlementBatchSummary do
52
52
  settlement_date = result[:transaction][:settlement_batch_id].split("_").first
53
53
  result = Braintree::SettlementBatchSummary.generate(settlement_date, "store_me")
54
54
 
55
- result.should be_success
55
+ expect(result).to be_success
56
56
  amex_records = result.settlement_batch_summary.records.select { |row| row[:store_me] == "1" }
57
- amex_records.should_not be_empty
58
- amex_records.first[:count].to_i.should >= 1
59
- amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
57
+ expect(amex_records).not_to be_empty
58
+ expect(amex_records.first[:count].to_i).to be >= 1
59
+ expect(amex_records.first[:amount_settled].to_i).to be >= Braintree::Test::TransactionAmounts::Authorize.to_i
60
60
  end
61
61
  end
62
62
  end