braintree 3.0.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +2 -3
  3. data/lib/braintree.rb +8 -1
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -1
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +1 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/bin_data.rb +9 -2
  11. data/lib/braintree/client_token.rb +1 -1
  12. data/lib/braintree/configuration.rb +11 -11
  13. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  14. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  15. data/lib/braintree/credit_card.rb +2 -2
  16. data/lib/braintree/credit_card_gateway.rb +4 -4
  17. data/lib/braintree/credit_card_verification.rb +5 -5
  18. data/lib/braintree/credit_card_verification_search.rb +1 -1
  19. data/lib/braintree/customer.rb +6 -4
  20. data/lib/braintree/customer_gateway.rb +2 -0
  21. data/lib/braintree/customer_search.rb +1 -1
  22. data/lib/braintree/disbursement.rb +1 -1
  23. data/lib/braintree/dispute.rb +15 -1
  24. data/lib/braintree/dispute/paypal_message.rb +15 -0
  25. data/lib/braintree/dispute_gateway.rb +2 -2
  26. data/lib/braintree/dispute_search.rb +3 -2
  27. data/lib/braintree/document_upload.rb +1 -1
  28. data/lib/braintree/error_codes.rb +10 -2
  29. data/lib/braintree/google_pay_card.rb +1 -1
  30. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  31. data/lib/braintree/graphql_client.rb +7 -7
  32. data/lib/braintree/http.rb +3 -3
  33. data/lib/braintree/local_payment_completed.rb +1 -1
  34. data/lib/braintree/local_payment_reversed.rb +19 -0
  35. data/lib/braintree/merchant.rb +1 -1
  36. data/lib/braintree/merchant_account.rb +1 -1
  37. data/lib/braintree/merchant_account_gateway.rb +1 -1
  38. data/lib/braintree/merchant_gateway.rb +1 -1
  39. data/lib/braintree/modification.rb +1 -1
  40. data/lib/braintree/oauth_credentials.rb +1 -1
  41. data/lib/braintree/oauth_gateway.rb +5 -5
  42. data/lib/braintree/payment_instrument_type.rb +10 -10
  43. data/lib/braintree/payment_method_gateway.rb +4 -6
  44. data/lib/braintree/payment_method_nonce.rb +1 -1
  45. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  46. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  47. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  48. data/lib/braintree/plan.rb +1 -1
  49. data/lib/braintree/processor_response_types.rb +3 -3
  50. data/lib/braintree/resource_collection.rb +8 -3
  51. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  52. data/lib/braintree/risk_data.rb +3 -1
  53. data/lib/braintree/samsung_pay_card.rb +1 -1
  54. data/lib/braintree/settlement_batch_summary.rb +2 -2
  55. data/lib/braintree/subscription.rb +6 -6
  56. data/lib/braintree/test/credit_card.rb +1 -0
  57. data/lib/braintree/three_d_secure_info.rb +22 -12
  58. data/lib/braintree/transaction.rb +43 -26
  59. data/lib/braintree/transaction/installment.rb +28 -0
  60. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  61. data/lib/braintree/transaction/paypal_details.rb +1 -0
  62. data/lib/braintree/transaction_gateway.rb +26 -5
  63. data/lib/braintree/transaction_line_item.rb +1 -1
  64. data/lib/braintree/transaction_search.rb +3 -1
  65. data/lib/braintree/unknown_payment_method.rb +1 -1
  66. data/lib/braintree/us_bank_account.rb +3 -3
  67. data/lib/braintree/us_bank_account_verification.rb +1 -1
  68. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  69. data/lib/braintree/util.rb +4 -4
  70. data/lib/braintree/venmo_account.rb +1 -1
  71. data/lib/braintree/version.rb +2 -2
  72. data/lib/braintree/visa_checkout_card.rb +2 -2
  73. data/lib/braintree/webhook_notification.rb +28 -19
  74. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  75. data/lib/braintree/webhook_testing_gateway.rb +10 -0
  76. data/lib/braintree/xml/generator.rb +5 -4
  77. data/lib/braintree/xml/libxml.rb +0 -1
  78. data/lib/braintree/xml/parser.rb +22 -12
  79. data/lib/braintree/xml/rexml.rb +70 -0
  80. data/spec/integration/braintree/add_on_spec.rb +1 -1
  81. data/spec/integration/braintree/address_spec.rb +28 -24
  82. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  83. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  84. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  85. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  86. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  87. data/spec/integration/braintree/credit_card_spec.rb +124 -122
  88. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  89. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  90. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  91. data/spec/integration/braintree/customer_spec.rb +343 -149
  92. data/spec/integration/braintree/dispute_search_spec.rb +29 -4
  93. data/spec/integration/braintree/dispute_spec.rb +6 -6
  94. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  95. data/spec/integration/braintree/http_spec.rb +2 -2
  96. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  97. data/spec/integration/braintree/merchant_spec.rb +14 -14
  98. data/spec/integration/braintree/oauth_spec.rb +11 -11
  99. data/spec/integration/braintree/payment_method_nonce_spec.rb +26 -35
  100. data/spec/integration/braintree/payment_method_spec.rb +326 -149
  101. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  102. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  103. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  104. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  105. data/spec/integration/braintree/subscription_spec.rb +133 -133
  106. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  107. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  108. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  109. data/spec/integration/braintree/transaction_spec.rb +736 -380
  110. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  111. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  112. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  113. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  114. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  115. data/spec/integration/spec_helper.rb +9 -3
  116. data/spec/oauth_test_helper.rb +1 -1
  117. data/spec/script/httpsd.rb +6 -6
  118. data/spec/spec_helper.rb +6 -3
  119. data/spec/unit/braintree/address_spec.rb +1 -1
  120. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  121. data/spec/unit/braintree/client_token_spec.rb +2 -2
  122. data/spec/unit/braintree/configuration_spec.rb +42 -42
  123. data/spec/unit/braintree/credit_card_spec.rb +9 -9
  124. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  125. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  126. data/spec/unit/braintree/customer_spec.rb +14 -4
  127. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  128. data/spec/unit/braintree/dispute_search_spec.rb +1 -0
  129. data/spec/unit/braintree/dispute_spec.rb +34 -9
  130. data/spec/unit/braintree/error_result_spec.rb +5 -5
  131. data/spec/unit/braintree/errors_spec.rb +8 -8
  132. data/spec/unit/braintree/http_spec.rb +5 -5
  133. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  134. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  135. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  136. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  137. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  138. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  139. data/spec/unit/braintree/risk_data_spec.rb +9 -5
  140. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  141. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  142. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  143. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  144. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  145. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  146. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  147. data/spec/unit/braintree/transaction/paypal_details_spec.rb +3 -1
  148. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  149. data/spec/unit/braintree/transaction_spec.rb +25 -17
  150. data/spec/unit/braintree/util_spec.rb +18 -18
  151. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  152. data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
  153. data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
  154. data/spec/unit/braintree/xml_spec.rb +31 -31
  155. metadata +15 -19
  156. data/lib/braintree/settlement_batch.rb +0 -0
@@ -5,7 +5,7 @@ describe Braintree::ValidationErrorCollection do
5
5
  context "blue response" do
6
6
  describe "initialize" do
7
7
  it "builds an error object given an array of hashes" do
8
- hash = {:errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }]}
8
+ hash = {:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}]}
9
9
  collection = Braintree::ValidationErrorCollection.new(hash)
10
10
  error = collection[0]
11
11
  error.attribute.should == "some model attribute"
@@ -17,9 +17,9 @@ describe Braintree::ValidationErrorCollection do
17
17
  describe "for" do
18
18
  it "provides access to nested errors" do
19
19
  hash = {
20
- :errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }],
20
+ :errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
21
21
  :nested => {
22
- :errors => [{ :attribute => "number", :code => 2, :message => "badder juju"}]
22
+ :errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
23
23
  }
24
24
  }
25
25
  errors = Braintree::ValidationErrorCollection.new(hash)
@@ -45,7 +45,7 @@ describe Braintree::ValidationErrorCollection do
45
45
  ],
46
46
  :level1 => {
47
47
  :errors => [{:attribute => "name", :code => "code2", :message => "message2"}]
48
- }
48
+ },
49
49
  )
50
50
  errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2]>"
51
51
  end
@@ -60,7 +60,7 @@ describe Braintree::ValidationErrorCollection do
60
60
  :level2 => {
61
61
  :errors => [{:attribute => "name", :code => "code3", :message => "message3"}],
62
62
  }
63
- }
63
+ },
64
64
  )
65
65
  errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2], level1/level2:[(code3) message3]>"
66
66
  end
@@ -74,12 +74,12 @@ describe Braintree::ValidationErrorCollection do
74
74
  {:attribute => "not name", :code => 3, :message => "is invalid"}
75
75
  ])
76
76
  errors.on("name").size.should == 2
77
- errors.on("name").map{ |e| e.code }.should == [1, 2]
77
+ errors.on("name").map { |e| e.code }.should == [1, 2]
78
78
  end
79
79
 
80
80
  it "has indifferent access" do
81
81
  errors = Braintree::ValidationErrorCollection.new(:errors => [
82
- { :attribute => "name", :code => 3, :message => "is too long" },
82
+ {:attribute => "name", :code => 3, :message => "is too long"},
83
83
  ])
84
84
  errors.on(:name).size.should == 1
85
85
  errors.on(:name)[0].code.should == 3
@@ -99,10 +99,10 @@ describe Braintree::ValidationErrorCollection do
99
99
 
100
100
  it "returns the size of nested errors as well" do
101
101
  errors = Braintree::ValidationErrorCollection.new(
102
- :errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }],
102
+ :errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
103
103
  :nested => {
104
- :errors => [{ :attribute => "number", :code => 2, :message => "badder juju"}]
105
- }
104
+ :errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
105
+ },
106
106
  )
107
107
  errors.deep_size.should == 2
108
108
  end
@@ -110,17 +110,17 @@ describe Braintree::ValidationErrorCollection do
110
110
  it "returns the size of multiple nestings of errors" do
111
111
  errors = Braintree::ValidationErrorCollection.new(
112
112
  :errors => [
113
- { :attribute => "one", :code => 1, :message => "bad juju" },
114
- { :attribute => "two", :code => 1, :message => "bad juju" }],
113
+ {:attribute => "one", :code => 1, :message => "bad juju"},
114
+ {:attribute => "two", :code => 1, :message => "bad juju"}],
115
115
  :nested => {
116
- :errors => [{ :attribute => "three", :code => 2, :message => "badder juju"}],
116
+ :errors => [{:attribute => "three", :code => 2, :message => "badder juju"}],
117
117
  :nested_again => {
118
- :errors => [{ :attribute => "four", :code => 2, :message => "badder juju"}]
118
+ :errors => [{:attribute => "four", :code => 2, :message => "badder juju"}]
119
119
  }
120
120
  },
121
121
  :same_level => {
122
- :errors => [{ :attribute => "five", :code => 2, :message => "badder juju"}],
123
- }
122
+ :errors => [{:attribute => "five", :code => 2, :message => "badder juju"}],
123
+ },
124
124
  )
125
125
  errors.deep_size.should == 5
126
126
  end
@@ -130,17 +130,17 @@ describe Braintree::ValidationErrorCollection do
130
130
  it "returns errors from all levels" do
131
131
  errors = Braintree::ValidationErrorCollection.new(
132
132
  :errors => [
133
- { :attribute => "one", :code => 1, :message => "bad juju" },
134
- { :attribute => "two", :code => 2, :message => "bad juju" }],
133
+ {:attribute => "one", :code => 1, :message => "bad juju"},
134
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
135
135
  :nested => {
136
- :errors => [{ :attribute => "three", :code => 3, :message => "badder juju"}],
136
+ :errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
137
137
  :nested_again => {
138
- :errors => [{ :attribute => "four", :code => 4, :message => "badder juju"}]
138
+ :errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
139
139
  }
140
140
  },
141
141
  :same_level => {
142
- :errors => [{ :attribute => "five", :code => 5, :message => "badder juju"}],
143
- }
142
+ :errors => [{:attribute => "five", :code => 5, :message => "badder juju"}],
143
+ },
144
144
  )
145
145
  errors.deep_errors.map { |e| e.code }.sort.should == [1, 2, 3, 4, 5]
146
146
  end
@@ -150,27 +150,27 @@ describe Braintree::ValidationErrorCollection do
150
150
  it "returns errors on one level" do
151
151
  errors = Braintree::ValidationErrorCollection.new(
152
152
  :errors => [
153
- { :attribute => "one", :code => 1, :message => "bad juju" },
154
- { :attribute => "two", :code => 2, :message => "bad juju" }],
153
+ {:attribute => "one", :code => 1, :message => "bad juju"},
154
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
155
155
  :nested => {
156
- :errors => [{ :attribute => "three", :code => 3, :message => "badder juju"}],
156
+ :errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
157
157
  :nested_again => {
158
- :errors => [{ :attribute => "four", :code => 4, :message => "badder juju"}]
158
+ :errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
159
159
  }
160
- }
160
+ },
161
161
  )
162
- errors.shallow_errors.map {|e| e.code}.should == [1, 2]
163
- errors.for(:nested).shallow_errors.map {|e| e.code}.should == [3]
162
+ errors.shallow_errors.map { |e| e.code }.should == [1, 2]
163
+ errors.for(:nested).shallow_errors.map { |e| e.code }.should == [3]
164
164
  end
165
165
 
166
166
  it "returns an clone of the real array" do
167
167
  errors = Braintree::ValidationErrorCollection.new(
168
168
  :errors => [
169
- { :attribute => "one", :code => 1, :message => "bad juju" },
170
- { :attribute => "two", :code => 2, :message => "bad juju" }]
169
+ {:attribute => "one", :code => 1, :message => "bad juju"},
170
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
171
171
  )
172
172
  errors.shallow_errors.pop
173
- errors.shallow_errors.map {|e| e.code}.should == [1, 2]
173
+ errors.shallow_errors.map { |e| e.code }.should == [1, 2]
174
174
  end
175
175
  end
176
176
  end
@@ -368,10 +368,10 @@ describe Braintree::ValidationErrorCollection do
368
368
  }
369
369
  }
370
370
  errors = Braintree::ValidationErrorCollection.new(hash)
371
- errors.shallow_errors.map {|e| e.code}.should == [1]
372
- errors.for(:nested).shallow_errors.map {|e| e.code}.should == [2,3]
373
- errors.for(:nested).for(:deeply_nested).shallow_errors.map {|e| e.code}.should == [4]
374
- errors.for(:nested_again).shallow_errors.map {|e| e.code}.should == [5]
371
+ errors.shallow_errors.map { |e| e.code }.should == [1]
372
+ errors.for(:nested).shallow_errors.map { |e| e.code }.should == [2,3]
373
+ errors.for(:nested).for(:deeply_nested).shallow_errors.map { |e| e.code }.should == [4]
374
+ errors.for(:nested_again).shallow_errors.map { |e| e.code }.should == [5]
375
375
  end
376
376
  end
377
377
  end
@@ -5,7 +5,7 @@ describe Braintree::WebhookNotification do
5
5
  it "builds a sample notification and signature given an identifier and kind" do
6
6
  sample_notification = Braintree::WebhookTesting.sample_notification(
7
7
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
8
- "my_id"
8
+ "my_id",
9
9
  )
10
10
 
11
11
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -18,7 +18,7 @@ describe Braintree::WebhookNotification do
18
18
  it "builds a sample notification for a partner merchant connected webhook" do
19
19
  sample_notification = Braintree::WebhookTesting.sample_notification(
20
20
  Braintree::WebhookNotification::Kind::PartnerMerchantConnected,
21
- "my_id"
21
+ "my_id",
22
22
  )
23
23
 
24
24
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -35,7 +35,7 @@ describe Braintree::WebhookNotification do
35
35
  it "builds a sample notification for a partner merchant disconnected webhook" do
36
36
  sample_notification = Braintree::WebhookTesting.sample_notification(
37
37
  Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected,
38
- "my_id"
38
+ "my_id",
39
39
  )
40
40
 
41
41
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -48,7 +48,7 @@ describe Braintree::WebhookNotification do
48
48
  it "builds a sample notification for a partner merchant declined webhook" do
49
49
  sample_notification = Braintree::WebhookTesting.sample_notification(
50
50
  Braintree::WebhookNotification::Kind::PartnerMerchantDeclined,
51
- "my_id"
51
+ "my_id",
52
52
  )
53
53
 
54
54
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -62,7 +62,7 @@ describe Braintree::WebhookNotification do
62
62
  sample_notification = Braintree::WebhookTesting.sample_notification(
63
63
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
64
64
  "my_id",
65
- "my_source_merchant_id"
65
+ "my_source_merchant_id",
66
66
  )
67
67
 
68
68
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -73,7 +73,7 @@ describe Braintree::WebhookNotification do
73
73
  it "doesn't include source merchant IDs if not supplied" do
74
74
  sample_notification = Braintree::WebhookTesting.sample_notification(
75
75
  Braintree::WebhookNotification::Kind::PartnerMerchantDeclined,
76
- "my_id"
76
+ "my_id",
77
77
  )
78
78
 
79
79
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -85,7 +85,7 @@ describe Braintree::WebhookNotification do
85
85
  it "builds a sample notification for a status transitioned webhook" do
86
86
  sample_notification = Braintree::WebhookTesting.sample_notification(
87
87
  Braintree::WebhookNotification::Kind::ConnectedMerchantStatusTransitioned,
88
- "my_id"
88
+ "my_id",
89
89
  )
90
90
 
91
91
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -102,7 +102,7 @@ describe Braintree::WebhookNotification do
102
102
  it "builds a sample notification for a paypal status changed webhook" do
103
103
  sample_notification = Braintree::WebhookTesting.sample_notification(
104
104
  Braintree::WebhookNotification::Kind::ConnectedMerchantPayPalStatusChanged,
105
- "my_id"
105
+ "my_id",
106
106
  )
107
107
 
108
108
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -116,10 +116,10 @@ describe Braintree::WebhookNotification do
116
116
  paypal_status_changed.action.should == "link"
117
117
  end
118
118
 
119
- it 'builds a sample notification for OAuth application revocation' do
119
+ it "builds a sample notification for OAuth application revocation" do
120
120
  sample_notification = Braintree::WebhookTesting.sample_notification(
121
121
  Braintree::WebhookNotification::Kind::OAuthAccessRevoked,
122
- 'my_id'
122
+ "my_id",
123
123
  )
124
124
 
125
125
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -139,7 +139,7 @@ describe Braintree::WebhookNotification do
139
139
  it "builds a sample notification for a dispute opened webhook" do
140
140
  sample_notification = Braintree::WebhookTesting.sample_notification(
141
141
  Braintree::WebhookNotification::Kind::DisputeOpened,
142
- dispute_id
142
+ dispute_id,
143
143
  )
144
144
 
145
145
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -155,7 +155,7 @@ describe Braintree::WebhookNotification do
155
155
  it "builds a sample notification for a dispute lost webhook" do
156
156
  sample_notification = Braintree::WebhookTesting.sample_notification(
157
157
  Braintree::WebhookNotification::Kind::DisputeLost,
158
- dispute_id
158
+ dispute_id,
159
159
  )
160
160
 
161
161
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -171,7 +171,7 @@ describe Braintree::WebhookNotification do
171
171
  it "builds a sample notification for a dispute won webhook" do
172
172
  sample_notification = Braintree::WebhookTesting.sample_notification(
173
173
  Braintree::WebhookNotification::Kind::DisputeWon,
174
- dispute_id
174
+ dispute_id,
175
175
  )
176
176
 
177
177
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -187,7 +187,7 @@ describe Braintree::WebhookNotification do
187
187
  it "builds a sample notification for a dispute accepted webhook" do
188
188
  sample_notification = Braintree::WebhookTesting.sample_notification(
189
189
  Braintree::WebhookNotification::Kind::DisputeAccepted,
190
- dispute_id
190
+ dispute_id,
191
191
  )
192
192
 
193
193
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -203,7 +203,7 @@ describe Braintree::WebhookNotification do
203
203
  it "builds a sample notification for a dispute disputed webhook" do
204
204
  sample_notification = Braintree::WebhookTesting.sample_notification(
205
205
  Braintree::WebhookNotification::Kind::DisputeDisputed,
206
- dispute_id
206
+ dispute_id,
207
207
  )
208
208
 
209
209
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -219,7 +219,7 @@ describe Braintree::WebhookNotification do
219
219
  it "builds a sample notification for a dispute expired webhook" do
220
220
  sample_notification = Braintree::WebhookTesting.sample_notification(
221
221
  Braintree::WebhookNotification::Kind::DisputeExpired,
222
- dispute_id
222
+ dispute_id,
223
223
  )
224
224
 
225
225
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -235,7 +235,7 @@ describe Braintree::WebhookNotification do
235
235
  it "is compatible with the previous dispute won webhook interface" do
236
236
  sample_notification = Braintree::WebhookTesting.sample_notification(
237
237
  Braintree::WebhookNotification::Kind::DisputeWon,
238
- dispute_id
238
+ dispute_id,
239
239
  )
240
240
 
241
241
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -267,7 +267,7 @@ describe Braintree::WebhookNotification do
267
267
  it "builds a sample notification for a transaction disbursed webhook" do
268
268
  sample_notification = Braintree::WebhookTesting.sample_notification(
269
269
  Braintree::WebhookNotification::Kind::TransactionDisbursed,
270
- "my_id"
270
+ "my_id",
271
271
  )
272
272
 
273
273
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -281,7 +281,7 @@ describe Braintree::WebhookNotification do
281
281
  it "builds a sample notification for a disbursement_exception webhook" do
282
282
  sample_notification = Braintree::WebhookTesting.sample_notification(
283
283
  Braintree::WebhookNotification::Kind::DisbursementException,
284
- "my_id"
284
+ "my_id",
285
285
  )
286
286
 
287
287
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -300,7 +300,7 @@ describe Braintree::WebhookNotification do
300
300
  it "builds a sample notification for a disbursement webhook" do
301
301
  sample_notification = Braintree::WebhookTesting.sample_notification(
302
302
  Braintree::WebhookNotification::Kind::Disbursement,
303
- "my_id"
303
+ "my_id",
304
304
  )
305
305
 
306
306
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -321,7 +321,7 @@ describe Braintree::WebhookNotification do
321
321
  it "builds a sample notification for a settlement webhook" do
322
322
  sample_notification = Braintree::WebhookTesting.sample_notification(
323
323
  Braintree::WebhookNotification::Kind::TransactionSettled,
324
- "my_id"
324
+ "my_id",
325
325
  )
326
326
 
327
327
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -338,7 +338,7 @@ describe Braintree::WebhookNotification do
338
338
  it "builds a sample notification for a settlement declined webhook" do
339
339
  sample_notification = Braintree::WebhookTesting.sample_notification(
340
340
  Braintree::WebhookNotification::Kind::TransactionSettlementDeclined,
341
- "my_id"
341
+ "my_id",
342
342
  )
343
343
 
344
344
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -357,7 +357,7 @@ describe Braintree::WebhookNotification do
357
357
  it "builds a sample notification for a merchant account approved webhook" do
358
358
  sample_notification = Braintree::WebhookTesting.sample_notification(
359
359
  Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
360
- "my_id"
360
+ "my_id",
361
361
  )
362
362
 
363
363
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -372,7 +372,7 @@ describe Braintree::WebhookNotification do
372
372
  it "builds a sample notification for a merchant account declined webhook" do
373
373
  sample_notification = Braintree::WebhookTesting.sample_notification(
374
374
  Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined,
375
- "my_id"
375
+ "my_id",
376
376
  )
377
377
 
378
378
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -391,7 +391,7 @@ describe Braintree::WebhookNotification do
391
391
  it "builds a sample notification for a subscription charged successfully webhook" do
392
392
  sample_notification = Braintree::WebhookTesting.sample_notification(
393
393
  Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully,
394
- "my_id"
394
+ "my_id",
395
395
  )
396
396
 
397
397
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -406,7 +406,7 @@ describe Braintree::WebhookNotification do
406
406
  it "builds a sample notification for a subscription charged unsuccessfully webhook" do
407
407
  sample_notification = Braintree::WebhookTesting.sample_notification(
408
408
  Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully,
409
- "my_id"
409
+ "my_id",
410
410
  )
411
411
 
412
412
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -422,7 +422,7 @@ describe Braintree::WebhookNotification do
422
422
  it "includes a valid signature" do
423
423
  sample_notification = Braintree::WebhookTesting.sample_notification(
424
424
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
425
- "my_id"
425
+ "my_id",
426
426
  )
427
427
  expected_signature = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, sample_notification[:bt_payload])
428
428
 
@@ -434,7 +434,7 @@ describe Braintree::WebhookNotification do
434
434
  it "builds a sample notification for an account_updater_daily_report webhook" do
435
435
  sample_notification = Braintree::WebhookTesting.sample_notification(
436
436
  Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport,
437
- "my_id"
437
+ "my_id",
438
438
  )
439
439
 
440
440
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -449,44 +449,44 @@ describe Braintree::WebhookNotification do
449
449
  it "builds a sample notification for a GrantorUpdatedGrantedPaymentMethod webhook" do
450
450
  sample_notification = Braintree::WebhookTesting.sample_notification(
451
451
  Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod,
452
- "my_id"
452
+ "my_id",
453
453
  )
454
454
 
455
455
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
456
456
  update = notification.granted_payment_instrument_update
457
457
 
458
458
  notification.kind.should == Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod
459
- update.grant_owner_merchant_id.should == 'vczo7jqrpwrsi2px'
460
- update.grant_recipient_merchant_id.should == 'cf0i8wgarszuy6hc'
461
- update.payment_method_nonce.should == 'ee257d98-de40-47e8-96b3-a6954ea7a9a4'
462
- update.token.should == 'abc123z'
463
- update.updated_fields.should == ['expiration-month', 'expiration-year']
459
+ update.grant_owner_merchant_id.should == "vczo7jqrpwrsi2px"
460
+ update.grant_recipient_merchant_id.should == "cf0i8wgarszuy6hc"
461
+ update.payment_method_nonce.should == "ee257d98-de40-47e8-96b3-a6954ea7a9a4"
462
+ update.token.should == "abc123z"
463
+ update.updated_fields.should == ["expiration-month", "expiration-year"]
464
464
  end
465
465
 
466
466
  it "builds a sample notification for a RecipientUpdatedGrantedPaymentMethod webhook" do
467
467
  sample_notification = Braintree::WebhookTesting.sample_notification(
468
468
  Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod,
469
- "my_id"
469
+ "my_id",
470
470
  )
471
471
 
472
472
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
473
473
  update = notification.granted_payment_instrument_update
474
474
 
475
475
  notification.kind.should == Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod
476
- update.grant_owner_merchant_id.should == 'vczo7jqrpwrsi2px'
477
- update.grant_recipient_merchant_id.should == 'cf0i8wgarszuy6hc'
478
- update.payment_method_nonce.should == 'ee257d98-de40-47e8-96b3-a6954ea7a9a4'
479
- update.token.should == 'abc123z'
480
- update.updated_fields.should == ['expiration-month', 'expiration-year']
476
+ update.grant_owner_merchant_id.should == "vczo7jqrpwrsi2px"
477
+ update.grant_recipient_merchant_id.should == "cf0i8wgarszuy6hc"
478
+ update.payment_method_nonce.should == "ee257d98-de40-47e8-96b3-a6954ea7a9a4"
479
+ update.token.should == "abc123z"
480
+ update.updated_fields.should == ["expiration-month", "expiration-year"]
481
481
  end
482
482
  end
483
483
 
484
484
  context "granted_payment_instrument_revoked" do
485
485
  let(:gateway) do
486
486
  config = Braintree::Configuration.new(
487
- :merchant_id => 'merchant_id',
488
- :public_key => 'wrong_public_key',
489
- :private_key => 'wrong_private_key'
487
+ :merchant_id => "merchant_id",
488
+ :public_key => "wrong_public_key",
489
+ :private_key => "wrong_private_key",
490
490
  )
491
491
  Braintree::Gateway.new(config)
492
492
  end
@@ -618,7 +618,7 @@ describe Braintree::WebhookNotification do
618
618
  it "builds a sample notification for a payment_method_revoked_by_customer webhook" do
619
619
  sample_notification = Braintree::WebhookTesting.sample_notification(
620
620
  Braintree::WebhookNotification::Kind::PaymentMethodRevokedByCustomer,
621
- "my_payment_method_token"
621
+ "my_payment_method_token",
622
622
  )
623
623
 
624
624
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -635,7 +635,7 @@ describe Braintree::WebhookNotification do
635
635
  it "builds a sample notification for a local_payment webhook" do
636
636
  sample_notification = Braintree::WebhookTesting.sample_notification(
637
637
  Braintree::WebhookNotification::Kind::LocalPaymentCompleted,
638
- "my_id"
638
+ "my_id",
639
639
  )
640
640
 
641
641
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -652,6 +652,22 @@ describe Braintree::WebhookNotification do
652
652
  end
653
653
  end
654
654
 
655
+
656
+ context "local_payment_reversed" do
657
+ it "builds a sample notification for a local_payment webhook" do
658
+ sample_notification = Braintree::WebhookTesting.sample_notification(
659
+ Braintree::WebhookNotification::Kind::LocalPaymentReversed,
660
+ "my_id",
661
+ )
662
+
663
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
664
+ notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentReversed
665
+
666
+ local_payment_reversed = notification.local_payment_reversed
667
+ local_payment_reversed.payment_id.should == "PAY-XYZ123"
668
+ end
669
+ end
670
+
655
671
  describe "parse" do
656
672
  it "raises InvalidSignature error when the signature is nil" do
657
673
  expect do
@@ -668,7 +684,7 @@ describe Braintree::WebhookNotification do
668
684
  it "raises InvalidSignature error when the signature is completely invalid" do
669
685
  sample_notification = Braintree::WebhookTesting.sample_notification(
670
686
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
671
- "my_id"
687
+ "my_id",
672
688
  )
673
689
 
674
690
  expect do
@@ -679,13 +695,13 @@ describe Braintree::WebhookNotification do
679
695
  it "raises InvalidSignature error with a message when the public key is not found" do
680
696
  sample_notification = Braintree::WebhookTesting.sample_notification(
681
697
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
682
- "my_id"
698
+ "my_id",
683
699
  )
684
700
 
685
701
  config = Braintree::Configuration.new(
686
- :merchant_id => 'merchant_id',
687
- :public_key => 'wrong_public_key',
688
- :private_key => 'wrong_private_key'
702
+ :merchant_id => "merchant_id",
703
+ :public_key => "wrong_public_key",
704
+ :private_key => "wrong_private_key",
689
705
  )
690
706
  gateway = Braintree::Gateway.new(config)
691
707
 
@@ -697,7 +713,7 @@ describe Braintree::WebhookNotification do
697
713
  it "raises InvalidSignature error if the payload has been changed" do
698
714
  sample_notification = Braintree::WebhookTesting.sample_notification(
699
715
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
700
- "my_id"
716
+ "my_id",
701
717
  )
702
718
 
703
719
  expect do
@@ -708,7 +724,7 @@ describe Braintree::WebhookNotification do
708
724
  it "raises InvalidSignature error with a message complaining about invalid characters" do
709
725
  sample_notification = Braintree::WebhookTesting.sample_notification(
710
726
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
711
- "my_id"
727
+ "my_id",
712
728
  )
713
729
 
714
730
  expect do
@@ -719,7 +735,7 @@ describe Braintree::WebhookNotification do
719
735
  it "allows all valid characters" do
720
736
  sample_notification = Braintree::WebhookTesting.sample_notification(
721
737
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
722
- "my_id"
738
+ "my_id",
723
739
  )
724
740
 
725
741
  sample_notification[:bt_payload] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+=/\n"
@@ -736,7 +752,7 @@ describe Braintree::WebhookNotification do
736
752
  it "retries a payload with a newline" do
737
753
  sample_notification = Braintree::WebhookTesting.sample_notification(
738
754
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
739
- "my_id"
755
+ "my_id",
740
756
  )
741
757
 
742
758
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
@@ -751,7 +767,7 @@ describe Braintree::WebhookNotification do
751
767
  it "returns true for check webhook kinds" do
752
768
  sample_notification = Braintree::WebhookTesting.sample_notification(
753
769
  Braintree::WebhookNotification::Kind::Check,
754
- nil
770
+ nil,
755
771
  )
756
772
 
757
773
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
@@ -762,7 +778,7 @@ describe Braintree::WebhookNotification do
762
778
  it "returns false for non-check webhook kinds" do
763
779
  sample_notification = Braintree::WebhookTesting.sample_notification(
764
780
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
765
- nil
781
+ nil,
766
782
  )
767
783
 
768
784
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)