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
@@ -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
|