braintree 2.76.0 → 2.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree.rb +12 -0
  3. data/lib/braintree/apple_pay.rb +29 -0
  4. data/lib/braintree/apple_pay_card.rb +1 -1
  5. data/lib/braintree/apple_pay_gateway.rb +37 -0
  6. data/lib/braintree/apple_pay_options.rb +19 -0
  7. data/lib/braintree/authorization_adjustment.rb +20 -0
  8. data/lib/braintree/dispute.rb +78 -9
  9. data/lib/braintree/dispute/evidence.rb +18 -0
  10. data/lib/braintree/dispute/history_event.rb +14 -0
  11. data/lib/braintree/dispute/transaction.rb +18 -0
  12. data/lib/braintree/dispute_gateway.rb +118 -0
  13. data/lib/braintree/dispute_search.rb +30 -0
  14. data/lib/braintree/document_upload.rb +34 -0
  15. data/lib/braintree/document_upload_gateway.rb +32 -0
  16. data/lib/braintree/error_codes.rb +17 -0
  17. data/lib/braintree/facilitated_details.rb +19 -0
  18. data/lib/braintree/gateway.rb +12 -0
  19. data/lib/braintree/http.rb +60 -12
  20. data/lib/braintree/successful_result.rb +1 -1
  21. data/lib/braintree/test/credit_card.rb +6 -0
  22. data/lib/braintree/transaction.rb +4 -0
  23. data/lib/braintree/version.rb +1 -1
  24. data/lib/braintree/webhook_testing_gateway.rb +196 -19
  25. data/spec/fixtures/files/bt_logo.png +0 -0
  26. data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
  27. data/spec/fixtures/files/malformed_pdf.pdf +1 -0
  28. data/spec/httpsd.pid +1 -1
  29. data/spec/integration/braintree/apple_pay_spec.rb +92 -0
  30. data/spec/integration/braintree/coinbase_spec.rb +15 -12
  31. data/spec/integration/braintree/dispute_search_spec.rb +49 -0
  32. data/spec/integration/braintree/dispute_spec.rb +216 -0
  33. data/spec/integration/braintree/document_upload_spec.rb +55 -0
  34. data/spec/integration/braintree/http_spec.rb +8 -0
  35. data/spec/integration/braintree/payment_method_spec.rb +5 -16
  36. data/spec/integration/braintree/transaction_spec.rb +21 -4
  37. data/spec/spec_helper.rb +3 -2
  38. data/spec/unit/braintree/apple_pay_card_spec.rb +6 -0
  39. data/spec/unit/braintree/dispute_search_spec.rb +59 -0
  40. data/spec/unit/braintree/dispute_spec.rb +331 -8
  41. data/spec/unit/braintree/document_upload_spec.rb +35 -0
  42. data/spec/unit/braintree/http_spec.rb +21 -0
  43. data/spec/unit/braintree/transaction_spec.rb +17 -0
  44. data/spec/unit/braintree/webhook_notification_spec.rb +74 -51
  45. metadata +24 -3
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::DocumentUpload do
4
+ describe "initialize" do
5
+ it "sets attributes" do
6
+ response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
7
+ document_upload = Braintree::DocumentUpload._new(response)
8
+ document_upload.id.should == "my_id"
9
+ document_upload.size.should == 555
10
+ document_upload.name.should == "up_file.pdf"
11
+ document_upload.content_type.should == "application/pdf"
12
+ document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
13
+ end
14
+ end
15
+
16
+ describe "kind" do
17
+ it "sets identity document" do
18
+ response = {:size => 555, :kind => "identity_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
19
+ document_upload = Braintree::DocumentUpload._new(response)
20
+ document_upload.kind.should == Braintree::DocumentUpload::Kind::IdentityDocument
21
+ end
22
+
23
+ it "sets evidence document" do
24
+ response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
25
+ document_upload = Braintree::DocumentUpload._new(response)
26
+ document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
27
+ end
28
+
29
+ it "sets payout invoice document" do
30
+ response = {:size => 555, :kind => "payout_invoice_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
31
+ document_upload = Braintree::DocumentUpload._new(response)
32
+ document_upload.kind.should == Braintree::DocumentUpload::Kind::PayoutInvoiceDocument
33
+ end
34
+ end
35
+ end
@@ -39,6 +39,27 @@ END
39
39
  Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
40
40
  end
41
41
 
42
+ it "sanitizes credit card number and cvv with newlines" do
43
+ input_xml = <<-END
44
+ <customer>
45
+ <first-name>Joe</first-name>
46
+ <last-name>Doe</last-name>
47
+ <number>123456000\n0001234</number>
48
+ <cvv>1\n23</cvv>
49
+ </customer>
50
+ END
51
+
52
+ expected_xml = <<-END
53
+ [Braintree] <customer>
54
+ [Braintree] <first-name>Joe</first-name>
55
+ [Braintree] <last-name>Doe</last-name>
56
+ [Braintree] <number>123456******1234</number>
57
+ [Braintree] <cvv>***</cvv>
58
+ [Braintree] </customer>
59
+ END
60
+ Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
61
+ end
62
+
42
63
  it "connects when proxy address is specified" do
43
64
  config = Braintree::Configuration.new(
44
65
  :proxy_address => "localhost",
@@ -209,6 +209,23 @@ describe Braintree::Transaction do
209
209
  transaction.status_history[1].user.should == "curly"
210
210
  end
211
211
 
212
+ it "sets up authorization_adjustments" do
213
+ timestamp = Time.utc(2010,1,14)
214
+ transaction = Braintree::Transaction._new(
215
+ :gateway,
216
+ :authorization_adjustments => [
217
+ { :timestamp => timestamp, :amount => "12.00", :success => true },
218
+ { :timestamp => timestamp, :amount => "12.34", :success => false },
219
+ ])
220
+ transaction.authorization_adjustments.size.should == 2
221
+ transaction.authorization_adjustments[0].amount.should == "12.00"
222
+ transaction.authorization_adjustments[0].success.should == true
223
+ transaction.authorization_adjustments[0].timestamp.should == timestamp
224
+ transaction.authorization_adjustments[1].amount.should == "12.34"
225
+ transaction.authorization_adjustments[1].success.should == false
226
+ transaction.authorization_adjustments[1].timestamp.should == timestamp
227
+ end
228
+
212
229
  it "handles receiving custom as an empty string" do
213
230
  transaction = Braintree::Transaction._new(
214
231
  :gateway,
@@ -93,56 +93,85 @@ describe Braintree::WebhookNotification do
93
93
  end
94
94
 
95
95
  context "disputes" do
96
- it "builds a sample notification for a dispute opened webhook" do
97
- sample_notification = Braintree::WebhookTesting.sample_notification(
98
- Braintree::WebhookNotification::Kind::DisputeOpened,
99
- "my_id"
100
- )
101
-
102
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
103
-
104
- notification.kind.should == Braintree::WebhookNotification::Kind::DisputeOpened
105
-
106
- dispute = notification.dispute
107
- dispute.status.should == Braintree::Dispute::Status::Open
108
- dispute.id.should == "my_id"
109
- dispute.kind.should == Braintree::Dispute::Kind::Chargeback
110
- dispute.date_opened.should == Date.new(2014,03,21)
96
+ let(:dispute_id) { "my_id" }
97
+
98
+ shared_examples "dispute webhooks" do
99
+ it "builds a sample notification for a dispute opened webhook" do
100
+ sample_notification = Braintree::WebhookTesting.sample_notification(
101
+ Braintree::WebhookNotification::Kind::DisputeOpened,
102
+ dispute_id
103
+ )
104
+
105
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
106
+
107
+ notification.kind.should == Braintree::WebhookNotification::Kind::DisputeOpened
108
+
109
+ dispute = notification.dispute
110
+ dispute.status.should == Braintree::Dispute::Status::Open
111
+ dispute.id.should == dispute_id
112
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
113
+ end
114
+
115
+ it "builds a sample notification for a dispute lost webhook" do
116
+ sample_notification = Braintree::WebhookTesting.sample_notification(
117
+ Braintree::WebhookNotification::Kind::DisputeLost,
118
+ dispute_id
119
+ )
120
+
121
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
122
+
123
+ notification.kind.should == Braintree::WebhookNotification::Kind::DisputeLost
124
+
125
+ dispute = notification.dispute
126
+ dispute.status.should == Braintree::Dispute::Status::Lost
127
+ dispute.id.should == dispute_id
128
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
129
+ end
130
+
131
+ it "builds a sample notification for a dispute won webhook" do
132
+ sample_notification = Braintree::WebhookTesting.sample_notification(
133
+ Braintree::WebhookNotification::Kind::DisputeWon,
134
+ dispute_id
135
+ )
136
+
137
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
138
+
139
+ notification.kind.should == Braintree::WebhookNotification::Kind::DisputeWon
140
+
141
+ dispute = notification.dispute
142
+ dispute.status.should == Braintree::Dispute::Status::Won
143
+ dispute.id.should == dispute_id
144
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
145
+ end
146
+
147
+ it "is compatible with the previous dispute won webhook interface" do
148
+ sample_notification = Braintree::WebhookTesting.sample_notification(
149
+ Braintree::WebhookNotification::Kind::DisputeWon,
150
+ dispute_id
151
+ )
152
+
153
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
154
+
155
+ notification.kind.should == Braintree::WebhookNotification::Kind::DisputeWon
156
+
157
+ dispute = notification.dispute
158
+ dispute.amount.should == 100.00
159
+ dispute.id.should == dispute_id
160
+ dispute.date_opened.should == Date.new(2014, 3, 21)
161
+ dispute.date_won.should == Date.new(2014, 3, 22)
162
+ dispute.transaction_details.amount.should == 100.00
163
+ dispute.transaction_details.id.should == dispute_id
164
+ end
111
165
  end
112
166
 
113
- it "builds a sample notification for a dispute lost webhook" do
114
- sample_notification = Braintree::WebhookTesting.sample_notification(
115
- Braintree::WebhookNotification::Kind::DisputeLost,
116
- "my_id"
117
- )
118
-
119
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
120
-
121
- notification.kind.should == Braintree::WebhookNotification::Kind::DisputeLost
167
+ context "older webhooks" do
168
+ let(:dispute_id) { "legacy_dispute_id" }
122
169
 
123
- dispute = notification.dispute
124
- dispute.status.should == Braintree::Dispute::Status::Lost
125
- dispute.id.should == "my_id"
126
- dispute.kind.should == Braintree::Dispute::Kind::Chargeback
127
- dispute.date_opened.should == Date.new(2014,03,21)
170
+ include_examples "dispute webhooks"
128
171
  end
129
172
 
130
- it "builds a sample notification for a dispute won webhook" do
131
- sample_notification = Braintree::WebhookTesting.sample_notification(
132
- Braintree::WebhookNotification::Kind::DisputeWon,
133
- "my_id"
134
- )
135
-
136
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
137
-
138
- notification.kind.should == Braintree::WebhookNotification::Kind::DisputeWon
139
-
140
- dispute = notification.dispute
141
- dispute.status.should == Braintree::Dispute::Status::Won
142
- dispute.id.should == "my_id"
143
- dispute.kind.should == Braintree::Dispute::Kind::Chargeback
144
- dispute.date_opened.should == Date.new(2014,03,21)
145
- dispute.date_won.should == Date.new(2014,03,22)
173
+ context "newer webhooks" do
174
+ include_examples "dispute webhooks"
146
175
  end
147
176
  end
148
177
 
@@ -253,12 +282,6 @@ describe Braintree::WebhookNotification do
253
282
  ideal_payment.amount.should == "10.00"
254
283
  ideal_payment.approval_url.should == "https://example.com"
255
284
  ideal_payment.ideal_transaction_id.should == "1234567890"
256
- ideal_payment.iban_bank_account.description.should == "DESCRIPTION ABC"
257
- ideal_payment.iban_bank_account.bic.should == "XXXXNLXX"
258
- ideal_payment.iban_bank_account.iban_country.should == "11"
259
- ideal_payment.iban_bank_account.iban_account_number_last_4.should == "0000"
260
- ideal_payment.iban_bank_account.masked_iban.should == "NL************0000"
261
- ideal_payment.iban_bank_account.account_holder_name.should == "Account Holder"
262
285
  end
263
286
 
264
287
  it "builds a sample notification for a ideal_payment_failed webhook" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.76.0
4
+ version: 2.77.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -44,7 +44,11 @@ files:
44
44
  - lib/braintree/advanced_search.rb
45
45
  - lib/braintree/amex_express_checkout_card.rb
46
46
  - lib/braintree/android_pay_card.rb
47
+ - lib/braintree/apple_pay.rb
47
48
  - lib/braintree/apple_pay_card.rb
49
+ - lib/braintree/apple_pay_gateway.rb
50
+ - lib/braintree/apple_pay_options.rb
51
+ - lib/braintree/authorization_adjustment.rb
48
52
  - lib/braintree/base_module.rb
49
53
  - lib/braintree/client_token.rb
50
54
  - lib/braintree/client_token_gateway.rb
@@ -67,13 +71,21 @@ files:
67
71
  - lib/braintree/discount.rb
68
72
  - lib/braintree/discount_gateway.rb
69
73
  - lib/braintree/dispute.rb
74
+ - lib/braintree/dispute/evidence.rb
75
+ - lib/braintree/dispute/history_event.rb
76
+ - lib/braintree/dispute/transaction.rb
70
77
  - lib/braintree/dispute/transaction_details.rb
78
+ - lib/braintree/dispute_gateway.rb
79
+ - lib/braintree/dispute_search.rb
80
+ - lib/braintree/document_upload.rb
81
+ - lib/braintree/document_upload_gateway.rb
71
82
  - lib/braintree/error_codes.rb
72
83
  - lib/braintree/error_result.rb
73
84
  - lib/braintree/errors.rb
74
85
  - lib/braintree/europe_bank_account.rb
75
86
  - lib/braintree/europe_bank_account_gateway.rb
76
87
  - lib/braintree/exceptions.rb
88
+ - lib/braintree/facilitated_details.rb
77
89
  - lib/braintree/facilitator_details.rb
78
90
  - lib/braintree/gateway.rb
79
91
  - lib/braintree/http.rb
@@ -163,11 +175,15 @@ files:
163
175
  - lib/braintree/xml/rexml.rb
164
176
  - lib/ssl/api_braintreegateway_com.ca.crt
165
177
  - lib/ssl/securetrust_ca.crt
178
+ - spec/fixtures/files/bt_logo.png
179
+ - spec/fixtures/files/gif_extension_bt_logo.gif
180
+ - spec/fixtures/files/malformed_pdf.pdf
166
181
  - spec/hacks/tcp_socket.rb
167
182
  - spec/httpsd.pid
168
183
  - spec/integration/braintree/add_on_spec.rb
169
184
  - spec/integration/braintree/address_spec.rb
170
185
  - spec/integration/braintree/advanced_search_spec.rb
186
+ - spec/integration/braintree/apple_pay_spec.rb
171
187
  - spec/integration/braintree/client_api/client_token_spec.rb
172
188
  - spec/integration/braintree/client_api/spec_helper.rb
173
189
  - spec/integration/braintree/coinbase_spec.rb
@@ -178,6 +194,9 @@ files:
178
194
  - spec/integration/braintree/customer_spec.rb
179
195
  - spec/integration/braintree/disbursement_spec.rb
180
196
  - spec/integration/braintree/discount_spec.rb
197
+ - spec/integration/braintree/dispute_search_spec.rb
198
+ - spec/integration/braintree/dispute_spec.rb
199
+ - spec/integration/braintree/document_upload_spec.rb
181
200
  - spec/integration/braintree/error_codes_spec.rb
182
201
  - spec/integration/braintree/http_spec.rb
183
202
  - spec/integration/braintree/ideal_payment_spec.rb
@@ -218,7 +237,9 @@ files:
218
237
  - spec/unit/braintree/customer_spec.rb
219
238
  - spec/unit/braintree/digest_spec.rb
220
239
  - spec/unit/braintree/disbursement_spec.rb
240
+ - spec/unit/braintree/dispute_search_spec.rb
221
241
  - spec/unit/braintree/dispute_spec.rb
242
+ - spec/unit/braintree/document_upload_spec.rb
222
243
  - spec/unit/braintree/error_result_spec.rb
223
244
  - spec/unit/braintree/errors_spec.rb
224
245
  - spec/unit/braintree/http_spec.rb
@@ -272,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
293
  version: '0'
273
294
  requirements: []
274
295
  rubyforge_project: braintree
275
- rubygems_version: 2.4.8
296
+ rubygems_version: 2.4.5.1
276
297
  signing_key:
277
298
  specification_version: 4
278
299
  summary: Braintree Gateway Ruby Client Library