braintree 4.14.0 → 4.16.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/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +22 -9
- data/lib/braintree/credit_card_gateway.rb +23 -11
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +1 -1
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +23 -10
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +4 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +1 -1
- data/lib/braintree/transaction/credit_card_details.rb +4 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +27 -20
- data/lib/braintree/transaction_gateway.rb +23 -12
- data/lib/braintree/transaction_line_item.rb +2 -2
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +7 -6
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +3 -2
- data/lib/braintree/webhook_notification_gateway.rb +3 -3
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +18 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +2 -2
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +4 -1
- 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_search_spec.rb +0 -1
- 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 +89 -69
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -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 +225 -165
- data/spec/integration/braintree/transaction_spec.rb +1502 -1210
- 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 +11 -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 +9 -9
- 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/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- 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 +39 -7
- 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 +12 -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 +16 -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 +11 -2
@@ -23,9 +23,9 @@ describe Braintree::Disbursement do
|
|
23
23
|
}
|
24
24
|
|
25
25
|
disbursement = Braintree::Disbursement._new(Braintree::Configuration.gateway, attributes)
|
26
|
-
disbursement.transactions.maximum_size.
|
26
|
+
expect(disbursement.transactions.maximum_size).to eq(1)
|
27
27
|
transaction = disbursement.transactions.first
|
28
|
-
transaction.id.
|
28
|
+
expect(transaction.id).to eq("sub_merchant_transaction")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -20,15 +20,15 @@ describe Braintree::Discount do
|
|
20
20
|
discounts = Braintree::Discount.all
|
21
21
|
discount = discounts.select { |discount| discount.id == id }.first
|
22
22
|
|
23
|
-
discount.
|
24
|
-
discount.amount.
|
25
|
-
discount.created_at.
|
26
|
-
discount.description.
|
27
|
-
discount.kind.
|
28
|
-
discount.name.
|
29
|
-
discount.never_expires.
|
30
|
-
discount.number_of_billing_cycles.
|
31
|
-
discount.updated_at.
|
23
|
+
expect(discount).not_to be_nil
|
24
|
+
expect(discount.amount).to eq(BigDecimal(expected[:amount]))
|
25
|
+
expect(discount.created_at).not_to be_nil
|
26
|
+
expect(discount.description).to eq(expected[:description])
|
27
|
+
expect(discount.kind).to eq(expected[:kind])
|
28
|
+
expect(discount.name).to eq(expected[:name])
|
29
|
+
expect(discount.never_expires).to eq(expected[:never_expires])
|
30
|
+
expect(discount.number_of_billing_cycles).to eq(expected[:number_of_billing_cycles])
|
31
|
+
expect(discount.updated_at).not_to be_nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -30,21 +30,21 @@ describe Braintree::Dispute do
|
|
30
30
|
it "changes the dispute status to accepted" do
|
31
31
|
result = Braintree::Dispute.accept(dispute.id)
|
32
32
|
|
33
|
-
result.success
|
33
|
+
expect(result.success?).to eq(true)
|
34
34
|
|
35
35
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
36
|
-
refreshed_dispute.status.
|
36
|
+
expect(refreshed_dispute.status).to eq(Braintree::Dispute::Status::Accepted)
|
37
37
|
|
38
38
|
dispute_from_transaction = Braintree::Transaction.find(dispute.transaction.id).disputes[0]
|
39
|
-
dispute_from_transaction.status.
|
39
|
+
expect(dispute_from_transaction.status).to eq(Braintree::Dispute::Status::Accepted)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns an error response if the dispute is not in open status" do
|
43
43
|
result = Braintree::Dispute.accept("wells_dispute")
|
44
44
|
|
45
|
-
result.success
|
46
|
-
result.errors.for(:dispute)[0].code.
|
47
|
-
result.errors.for(:dispute)[0].message.
|
45
|
+
expect(result.success?).to eq(false)
|
46
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAcceptOpenDispute)
|
47
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Disputes can only be accepted when they are in an Open state")
|
48
48
|
end
|
49
49
|
|
50
50
|
it "raises a NotFound exception if the dispute cannot be found" do
|
@@ -58,13 +58,13 @@ describe Braintree::Dispute do
|
|
58
58
|
it "creates file evidence for the dispute" do
|
59
59
|
result = Braintree::Dispute.add_file_evidence(dispute.id, document_upload.id)
|
60
60
|
|
61
|
-
result.success
|
62
|
-
result.evidence.category.
|
63
|
-
result.evidence.comment.
|
64
|
-
result.evidence.created_at.between?(Time.now - 10, Time.now).
|
65
|
-
result.evidence.id.
|
66
|
-
result.evidence.sent_to_processor_at.
|
67
|
-
result.evidence.url.
|
61
|
+
expect(result.success?).to eq(true)
|
62
|
+
expect(result.evidence.category).to be_nil
|
63
|
+
expect(result.evidence.comment).to be_nil
|
64
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
65
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
66
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
67
|
+
expect(result.evidence.url).to include("bt_logo.png")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -77,9 +77,9 @@ describe Braintree::Dispute do
|
|
77
77
|
Braintree::Dispute.accept(dispute.id)
|
78
78
|
|
79
79
|
result = Braintree::Dispute.add_file_evidence(dispute.id, document_upload.id)
|
80
|
-
result.success
|
81
|
-
result.errors.for(:dispute)[0].code.
|
82
|
-
result.errors.for(:dispute)[0].message.
|
80
|
+
expect(result.success?).to eq(false)
|
81
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAddEvidenceToOpenDispute)
|
82
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be attached to disputes that are in an Open state")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns the new evidence record in subsequent dispute finds" do
|
@@ -87,17 +87,17 @@ describe Braintree::Dispute do
|
|
87
87
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
88
88
|
|
89
89
|
expected_evidence = refreshed_dispute.evidence.find { |e| e.id == result.evidence.id }
|
90
|
-
expected_evidence.
|
91
|
-
expected_evidence.comment.
|
92
|
-
expected_evidence.url.
|
90
|
+
expect(expected_evidence).not_to eq(nil)
|
91
|
+
expect(expected_evidence.comment).to be_nil
|
92
|
+
expect(expected_evidence.url).to include("bt_logo.png")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "creates file evidence with a category when provided" do
|
96
96
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "GENERAL", document_id: document_upload.id})
|
97
97
|
|
98
|
-
result.success
|
99
|
-
result.evidence.category.
|
100
|
-
result.evidence.url.
|
98
|
+
expect(result.success?).to eq(true)
|
99
|
+
expect(result.evidence.category).to eq("GENERAL")
|
100
|
+
expect(result.evidence.url).to include("bt_logo.png")
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -105,15 +105,15 @@ describe Braintree::Dispute do
|
|
105
105
|
it "creates text evidence for the dispute" do
|
106
106
|
result = Braintree::Dispute.add_text_evidence(dispute.id, "text evidence")
|
107
107
|
|
108
|
-
result.success
|
109
|
-
result.evidence.category.
|
110
|
-
result.evidence.comment.
|
111
|
-
result.evidence.created_at.between?(Time.now - 10, Time.now).
|
112
|
-
result.evidence.id.
|
113
|
-
result.evidence.sent_to_processor_at.
|
114
|
-
result.evidence.url.
|
115
|
-
result.evidence.tag.
|
116
|
-
result.evidence.sequence_number.
|
108
|
+
expect(result.success?).to eq(true)
|
109
|
+
expect(result.evidence.category).to eq(nil)
|
110
|
+
expect(result.evidence.comment).to eq("text evidence")
|
111
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
112
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
113
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
114
|
+
expect(result.evidence.url).to eq(nil)
|
115
|
+
expect(result.evidence.tag).to eq(nil)
|
116
|
+
expect(result.evidence.sequence_number).to eq(nil)
|
117
117
|
end
|
118
118
|
|
119
119
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -126,9 +126,9 @@ describe Braintree::Dispute do
|
|
126
126
|
Braintree::Dispute.accept(dispute.id)
|
127
127
|
|
128
128
|
result = Braintree::Dispute.add_text_evidence(dispute.id, "text evidence")
|
129
|
-
result.success
|
130
|
-
result.errors.for(:dispute)[0].code.
|
131
|
-
result.errors.for(:dispute)[0].message.
|
129
|
+
expect(result.success?).to eq(false)
|
130
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAddEvidenceToOpenDispute)
|
131
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be attached to disputes that are in an Open state")
|
132
132
|
end
|
133
133
|
|
134
134
|
it "returns the new evidence record in subsequent dispute finds" do
|
@@ -136,47 +136,47 @@ describe Braintree::Dispute do
|
|
136
136
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
137
137
|
|
138
138
|
expected_evidence = refreshed_dispute.evidence.find { |e| e.id == result.evidence.id }
|
139
|
-
expected_evidence.
|
140
|
-
expected_evidence.comment.
|
139
|
+
expect(expected_evidence).not_to eq(nil)
|
140
|
+
expect(expected_evidence.comment).to eq("text evidence")
|
141
141
|
end
|
142
142
|
|
143
143
|
it "creates text evidence for the dispute with optional parameters" do
|
144
144
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "123456789", category: "REFUND_ID", sequence_number: 7})
|
145
145
|
|
146
|
-
result.success
|
147
|
-
result.evidence.category.
|
148
|
-
result.evidence.comment.
|
149
|
-
result.evidence.created_at.between?(Time.now - 10, Time.now).
|
150
|
-
result.evidence.id.
|
151
|
-
result.evidence.sent_to_processor_at.
|
152
|
-
result.evidence.sequence_number.
|
146
|
+
expect(result.success?).to eq(true)
|
147
|
+
expect(result.evidence.category).to eq("REFUND_ID")
|
148
|
+
expect(result.evidence.comment).to eq("123456789")
|
149
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
150
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
151
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
152
|
+
expect(result.evidence.sequence_number).to eq(7)
|
153
153
|
end
|
154
154
|
|
155
155
|
it "creates text evidence for the dispute with CARRIER_NAME shipping tracking" do
|
156
156
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "UPS", category: "CARRIER_NAME", sequence_number: 0})
|
157
157
|
|
158
|
-
result.success
|
159
|
-
result.evidence.category.
|
160
|
-
result.evidence.comment.
|
161
|
-
result.evidence.sequence_number.
|
158
|
+
expect(result.success?).to eq(true)
|
159
|
+
expect(result.evidence.category).to eq("CARRIER_NAME")
|
160
|
+
expect(result.evidence.comment).to eq("UPS")
|
161
|
+
expect(result.evidence.sequence_number).to eq(0)
|
162
162
|
end
|
163
163
|
|
164
164
|
it "creates text evidence for the dispute with TRACKING_NUMBER shipping tracking" do
|
165
165
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "3", category: "TRACKING_NUMBER", sequence_number: 0})
|
166
166
|
|
167
|
-
result.success
|
168
|
-
result.evidence.category.
|
169
|
-
result.evidence.comment.
|
170
|
-
result.evidence.sequence_number.
|
167
|
+
expect(result.success?).to eq(true)
|
168
|
+
expect(result.evidence.category).to eq("TRACKING_NUMBER")
|
169
|
+
expect(result.evidence.comment).to eq("3")
|
170
|
+
expect(result.evidence.sequence_number).to eq(0)
|
171
171
|
end
|
172
172
|
|
173
173
|
it "creates text evidence for the dispute with TRACKING_URL shipping tracking" do
|
174
174
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "https://example.com/tracking-number/abc12345", category: "TRACKING_URL", sequence_number: 1})
|
175
175
|
|
176
|
-
result.success
|
177
|
-
result.evidence.category.
|
178
|
-
result.evidence.comment.
|
179
|
-
result.evidence.sequence_number.
|
176
|
+
expect(result.success?).to eq(true)
|
177
|
+
expect(result.evidence.category).to eq("TRACKING_URL")
|
178
|
+
expect(result.evidence.comment).to eq("https://example.com/tracking-number/abc12345")
|
179
|
+
expect(result.evidence.sequence_number).to eq(1)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -184,18 +184,18 @@ describe Braintree::Dispute do
|
|
184
184
|
it "changes the dispute status to disputed" do
|
185
185
|
result = Braintree::Dispute.finalize(dispute.id)
|
186
186
|
|
187
|
-
result.success
|
187
|
+
expect(result.success?).to eq(true)
|
188
188
|
|
189
189
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
190
|
-
refreshed_dispute.status.
|
190
|
+
expect(refreshed_dispute.status).to eq(Braintree::Dispute::Status::Disputed)
|
191
191
|
end
|
192
192
|
|
193
193
|
it "returns an error response if the dispute is not in open status" do
|
194
194
|
result = Braintree::Dispute.finalize("wells_dispute")
|
195
195
|
|
196
|
-
result.success
|
197
|
-
result.errors.for(:dispute)[0].code.
|
198
|
-
result.errors.for(:dispute)[0].message.
|
196
|
+
expect(result.success?).to eq(false)
|
197
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyFinalizeOpenDispute)
|
198
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Disputes can only be finalized when they are in an Open state")
|
199
199
|
end
|
200
200
|
|
201
201
|
it "raises a NotFound exception if the dispute cannot be found" do
|
@@ -209,13 +209,13 @@ describe Braintree::Dispute do
|
|
209
209
|
it "finds the dispute with the given id" do
|
210
210
|
dispute = Braintree::Dispute.find("open_dispute")
|
211
211
|
|
212
|
-
dispute.amount_disputed.
|
213
|
-
dispute.amount_won.
|
214
|
-
dispute.id.
|
215
|
-
dispute.graphql_id.
|
216
|
-
dispute.status.
|
217
|
-
dispute.transaction.amount.
|
218
|
-
dispute.transaction.id.
|
212
|
+
expect(dispute.amount_disputed).to eq(31.0)
|
213
|
+
expect(dispute.amount_won).to eq(0.0)
|
214
|
+
expect(dispute.id).to eq("open_dispute")
|
215
|
+
expect(dispute.graphql_id).not_to be_nil
|
216
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Open)
|
217
|
+
expect(dispute.transaction.amount).to eq(31.0)
|
218
|
+
expect(dispute.transaction.id).to eq("open_disputed_transaction")
|
219
219
|
end
|
220
220
|
|
221
221
|
it "raises an ArgumentError if dispute_id is not a string" do
|
@@ -243,7 +243,7 @@ describe Braintree::Dispute do
|
|
243
243
|
it "removes evidence from the dispute" do
|
244
244
|
result = Braintree::Dispute.remove_evidence(dispute.id, evidence.id)
|
245
245
|
|
246
|
-
result.success
|
246
|
+
expect(result.success?).to eq(true)
|
247
247
|
end
|
248
248
|
|
249
249
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -263,9 +263,9 @@ describe Braintree::Dispute do
|
|
263
263
|
Braintree::Dispute.accept(dispute.id)
|
264
264
|
|
265
265
|
result = Braintree::Dispute.remove_evidence(dispute.id, evidence.id)
|
266
|
-
result.success
|
267
|
-
result.errors.for(:dispute)[0].code.
|
268
|
-
result.errors.for(:dispute)[0].message.
|
266
|
+
expect(result.success?).to eq(false)
|
267
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyRemoveEvidenceFromOpenDispute)
|
268
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be removed from disputes that are in an Open state")
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
@@ -273,61 +273,61 @@ describe Braintree::Dispute do
|
|
273
273
|
it "fails to create file evidence for an unsupported category" do
|
274
274
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "NOTREALCATEGORY", document_id: document_upload.id})
|
275
275
|
|
276
|
-
result.success
|
277
|
-
result.errors.for(:dispute)[0].code.
|
276
|
+
expect(result.success?).to eq(false)
|
277
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyCreateEvidenceWithValidCategory)
|
278
278
|
end
|
279
279
|
|
280
280
|
it "fails to create text evidence for an unsupported category" do
|
281
281
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "NOTREALCATEGORY", content: "evidence"})
|
282
282
|
|
283
|
-
result.success
|
284
|
-
result.errors.for(:dispute)[0].code.
|
283
|
+
expect(result.success?).to eq(false)
|
284
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyCreateEvidenceWithValidCategory)
|
285
285
|
end
|
286
286
|
|
287
287
|
it "fails to create text evidence for a file only category MERCHANT_WEBSITE_OR_APP_ACCESS" do
|
288
288
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "MERCHANT_WEBSITE_OR_APP_ACCESS", content: "evidence"})
|
289
289
|
|
290
|
-
result.success
|
291
|
-
result.errors.for(:dispute)[0].code.
|
290
|
+
expect(result.success?).to eq(false)
|
291
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceCategoryDocumentOnly)
|
292
292
|
end
|
293
293
|
|
294
294
|
it "fails to create file evidence for a text only category DEVICE_ID" do
|
295
295
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "DEVICE_ID", document_id: document_upload.id})
|
296
296
|
|
297
|
-
result.success
|
298
|
-
result.errors.for(:dispute)[0].code.
|
297
|
+
expect(result.success?).to eq(false)
|
298
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceCategoryTextOnly)
|
299
299
|
end
|
300
300
|
|
301
301
|
it "fails to create evidence with an invalid date time format" do
|
302
302
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "DOWNLOAD_DATE_TIME", content: "baddate"})
|
303
303
|
|
304
|
-
result.success
|
305
|
-
result.errors.for(:dispute)[0].code.
|
304
|
+
expect(result.success?).to eq(false)
|
305
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceContentDateInvalid)
|
306
306
|
end
|
307
307
|
|
308
308
|
it "successfully creates text evidence with an valid date time format" do
|
309
309
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "DOWNLOAD_DATE_TIME", content: "2018-10-20T18:00:00-0500"})
|
310
310
|
|
311
|
-
result.success
|
311
|
+
expect(result.success?).to eq(true)
|
312
312
|
end
|
313
313
|
|
314
314
|
it "fails to finalize a dispute with digital goods missing" do
|
315
315
|
Braintree::Dispute.add_text_evidence(dispute.id, {category: "DEVICE_ID", content: "iphone_id"})
|
316
316
|
result = Braintree::Dispute.finalize(dispute.id)
|
317
317
|
|
318
|
-
result.success
|
318
|
+
expect(result.success?).to eq(false)
|
319
319
|
error_codes = result.errors.for(:dispute).map(&:code)
|
320
320
|
|
321
|
-
error_codes.
|
322
|
-
error_codes.
|
321
|
+
expect(error_codes).to include(Braintree::ErrorCodes::Dispute::DigitalGoodsMissingDownloadDate)
|
322
|
+
expect(error_codes).to include(Braintree::ErrorCodes::Dispute::DigitalGoodsMissingEvidence)
|
323
323
|
end
|
324
324
|
|
325
325
|
it "fails to finalize a dispute with partial non-disputed transaction information provided" do
|
326
326
|
Braintree::Dispute.add_text_evidence(dispute.id, {category: "PRIOR_NON_DISPUTED_TRANSACTION_ARN", content: "123"})
|
327
327
|
result = Braintree::Dispute.finalize(dispute.id)
|
328
328
|
|
329
|
-
result.success
|
330
|
-
result.errors.for(:dispute)[0].code.
|
329
|
+
expect(result.success?).to eq(false)
|
330
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::NonDisputedPriorTransactionEvidenceMissingDate)
|
331
331
|
end
|
332
332
|
end
|
333
333
|
end
|
@@ -7,30 +7,30 @@ describe Braintree::DocumentUploadGateway do
|
|
7
7
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
8
8
|
document_upload = response.document_upload
|
9
9
|
|
10
|
-
response.success
|
11
|
-
document_upload.id.
|
12
|
-
document_upload.content_type.
|
13
|
-
document_upload.kind.
|
14
|
-
document_upload.name.
|
15
|
-
document_upload.size.
|
10
|
+
expect(response.success?).to eq(true)
|
11
|
+
expect(document_upload.id).not_to be_nil
|
12
|
+
expect(document_upload.content_type).to eq("image/png")
|
13
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
14
|
+
expect(document_upload.name).to eq("bt_logo.png")
|
15
|
+
expect(document_upload.size).to eq(2443)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns file type error with unsupported file type" do
|
19
19
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/gif_extension_bt_logo.gif", "r")
|
20
20
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
21
|
-
response.errors.for(:document_upload).first.code.
|
21
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileTypeIsInvalid)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns malformed error with malformed file" do
|
25
25
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/malformed_pdf.pdf", "r")
|
26
26
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
27
|
-
response.errors.for(:document_upload).first.code.
|
27
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsMalformedOrEncrypted)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns invalid kind error with invalid kind" do
|
31
31
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
|
32
32
|
response = Braintree::DocumentUpload.create({:kind => "invalid_kind", :file => file})
|
33
|
-
response.errors.for(:document_upload).first.code.
|
33
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::KindIsInvalid)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns file too large error with file over 4mb" do
|
@@ -40,7 +40,7 @@ describe Braintree::DocumentUploadGateway do
|
|
40
40
|
File.open(filename, "w+") { |f| write_times.times { f.write "a" } }
|
41
41
|
file = File.new(filename, "r")
|
42
42
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
43
|
-
response.errors.for(:document_upload).first.code.
|
43
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsTooLarge)
|
44
44
|
ensure
|
45
45
|
File.delete(filename)
|
46
46
|
end
|
@@ -52,7 +52,7 @@ describe Braintree::DocumentUploadGateway do
|
|
52
52
|
File.open(filename, "w+") {}
|
53
53
|
file = File.new(filename, "r")
|
54
54
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
55
|
-
response.errors.for(:document_upload).first.code.
|
55
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsEmpty)
|
56
56
|
ensure
|
57
57
|
File.delete(filename)
|
58
58
|
end
|
@@ -62,7 +62,7 @@ describe Braintree::DocumentUploadGateway do
|
|
62
62
|
filename = "#{File.dirname(__FILE__)}/../../fixtures/files/too_long.pdf"
|
63
63
|
file = File.new(filename, "r")
|
64
64
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
65
|
-
response.errors.for(:document_upload).first.code.
|
65
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsTooLong)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "returns invalid keys error if signature is invalid" do
|
@@ -77,11 +77,11 @@ describe Braintree::DocumentUploadGateway do
|
|
77
77
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
|
78
78
|
document_upload = Braintree::DocumentUpload.create!({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
79
79
|
|
80
|
-
document_upload.id.
|
81
|
-
document_upload.content_type.
|
82
|
-
document_upload.kind.
|
83
|
-
document_upload.name.
|
84
|
-
document_upload.size.
|
80
|
+
expect(document_upload.id).not_to be_nil
|
81
|
+
expect(document_upload.content_type).to eq("image/png")
|
82
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
83
|
+
expect(document_upload.name).to eq("bt_logo.png")
|
84
|
+
expect(document_upload.size).to eq(2443)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -8,8 +8,8 @@ describe Braintree::ErrorCodes do
|
|
8
8
|
:cardholder_name => "x" * 256
|
9
9
|
},
|
10
10
|
)
|
11
|
-
result.success
|
12
|
-
result.errors.for(:customer).for(:credit_card).map { |e| e.code }.
|
11
|
+
expect(result.success?).to eq(false)
|
12
|
+
expect(result.errors.for(:customer).for(:credit_card).map { |e| e.code }).to \
|
13
13
|
include(Braintree::ErrorCodes::CreditCard::CardholderNameIsTooLong)
|
14
14
|
end
|
15
15
|
end
|