braintree 4.14.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- 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.
|
29
|
-
sepa_direct_debit_account.last_4.
|
30
|
-
sepa_direct_debit_account.default.
|
31
|
-
sepa_direct_debit_account.customer_id.
|
32
|
-
sepa_direct_debit_account.global_id.
|
33
|
-
sepa_direct_debit_account.customer_global_id.
|
34
|
-
sepa_direct_debit_account.bank_reference_token.
|
35
|
-
sepa_direct_debit_account.mandate_type.
|
36
|
-
sepa_direct_debit_account.merchant_or_partner_customer_id.
|
37
|
-
sepa_direct_debit_account.token.
|
38
|
-
sepa_direct_debit_account.image_url.
|
39
|
-
sepa_direct_debit_account.created_at.
|
40
|
-
sepa_direct_debit_account.updated_at.
|
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
|
-
|
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
|
-
|
114
|
+
is_expected.to be_success
|
115
115
|
|
116
116
|
transaction = subject.transaction
|
117
|
-
transaction.amount.
|
118
|
-
transaction.status.
|
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.
|
121
|
-
sepa_direct_debit_account_details.bank_reference_token.
|
122
|
-
sepa_direct_debit_account_details.capture_id.
|
123
|
-
sepa_direct_debit_account_details.debug_id.
|
124
|
-
sepa_direct_debit_account_details.global_id.
|
125
|
-
sepa_direct_debit_account_details.last_4.
|
126
|
-
sepa_direct_debit_account_details.mandate_type.
|
127
|
-
sepa_direct_debit_account_details.merchant_or_partner_customer_id.
|
128
|
-
sepa_direct_debit_account_details.paypal_v2_order_id.
|
129
|
-
sepa_direct_debit_account_details.refund_from_transaction_fee_amount.
|
130
|
-
sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.
|
131
|
-
sepa_direct_debit_account_details.refund_id.
|
132
|
-
sepa_direct_debit_account_details.settlement_type.
|
133
|
-
sepa_direct_debit_account_details.token.
|
134
|
-
sepa_direct_debit_account_details.transaction_fee_amount.
|
135
|
-
sepa_direct_debit_account_details.transaction_fee_currency_iso_code.
|
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.
|
165
|
-
transaction.status.
|
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.
|
168
|
-
sepa_direct_debit_account_details.bank_reference_token.
|
169
|
-
sepa_direct_debit_account_details.capture_id.
|
170
|
-
sepa_direct_debit_account_details.debug_id.
|
171
|
-
sepa_direct_debit_account_details.global_id.
|
172
|
-
sepa_direct_debit_account_details.last_4.
|
173
|
-
sepa_direct_debit_account_details.mandate_type.
|
174
|
-
sepa_direct_debit_account_details.merchant_or_partner_customer_id.
|
175
|
-
sepa_direct_debit_account_details.paypal_v2_order_id.
|
176
|
-
sepa_direct_debit_account_details.refund_from_transaction_fee_amount.
|
177
|
-
sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.
|
178
|
-
sepa_direct_debit_account_details.refund_id.
|
179
|
-
sepa_direct_debit_account_details.settlement_type.
|
180
|
-
sepa_direct_debit_account_details.token.
|
181
|
-
sepa_direct_debit_account_details.transaction_fee_amount.
|
182
|
-
sepa_direct_debit_account_details.transaction_fee_currency_iso_code.
|
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.
|
9
|
-
result.settlement_batch_summary.records.size.
|
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.
|
15
|
-
result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }.
|
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.
|
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.
|
35
|
-
amex_records.first[:amount_settled].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.
|
55
|
+
expect(result).to be_success
|
56
56
|
amex_records = result.settlement_batch_summary.records.select { |row| row[:store_me] == "1" }
|
57
|
-
amex_records.
|
58
|
-
amex_records.first[:count].to_i.
|
59
|
-
amex_records.first[:amount_settled].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
|