braintree 3.2.0 → 4.2.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +3 -3
  3. data/lib/braintree.rb +6 -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/client_token.rb +1 -1
  11. data/lib/braintree/configuration.rb +11 -11
  12. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  13. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  14. data/lib/braintree/credit_card.rb +2 -2
  15. data/lib/braintree/credit_card_gateway.rb +14 -4
  16. data/lib/braintree/credit_card_verification.rb +5 -5
  17. data/lib/braintree/credit_card_verification_search.rb +1 -1
  18. data/lib/braintree/customer.rb +6 -4
  19. data/lib/braintree/customer_gateway.rb +2 -0
  20. data/lib/braintree/customer_search.rb +1 -1
  21. data/lib/braintree/disbursement.rb +1 -1
  22. data/lib/braintree/dispute.rb +15 -1
  23. data/lib/braintree/dispute/paypal_message.rb +15 -0
  24. data/lib/braintree/dispute_gateway.rb +2 -2
  25. data/lib/braintree/dispute_search.rb +3 -2
  26. data/lib/braintree/document_upload.rb +1 -1
  27. data/lib/braintree/error_codes.rb +10 -6
  28. data/lib/braintree/google_pay_card.rb +1 -1
  29. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  30. data/lib/braintree/graphql_client.rb +7 -7
  31. data/lib/braintree/http.rb +3 -3
  32. data/lib/braintree/local_payment_completed.rb +1 -1
  33. data/lib/braintree/local_payment_reversed.rb +19 -0
  34. data/lib/braintree/merchant.rb +1 -1
  35. data/lib/braintree/merchant_account.rb +1 -1
  36. data/lib/braintree/merchant_account_gateway.rb +1 -1
  37. data/lib/braintree/merchant_gateway.rb +1 -1
  38. data/lib/braintree/modification.rb +1 -1
  39. data/lib/braintree/oauth_credentials.rb +1 -1
  40. data/lib/braintree/oauth_gateway.rb +5 -5
  41. data/lib/braintree/payment_instrument_type.rb +10 -10
  42. data/lib/braintree/payment_method_gateway.rb +10 -7
  43. data/lib/braintree/payment_method_nonce.rb +7 -4
  44. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  45. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  46. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  47. data/lib/braintree/plan.rb +1 -1
  48. data/lib/braintree/processor_response_types.rb +3 -3
  49. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  50. data/lib/braintree/risk_data.rb +3 -1
  51. data/lib/braintree/samsung_pay_card.rb +1 -1
  52. data/lib/braintree/settlement_batch_summary.rb +2 -2
  53. data/lib/braintree/subscription.rb +6 -6
  54. data/lib/braintree/three_d_secure_info.rb +22 -12
  55. data/lib/braintree/transaction.rb +32 -24
  56. data/lib/braintree/transaction_gateway.rb +24 -5
  57. data/lib/braintree/transaction_line_item.rb +1 -1
  58. data/lib/braintree/transaction_search.rb +3 -1
  59. data/lib/braintree/unknown_payment_method.rb +1 -1
  60. data/lib/braintree/us_bank_account.rb +3 -3
  61. data/lib/braintree/us_bank_account_verification.rb +1 -1
  62. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  63. data/lib/braintree/util.rb +4 -4
  64. data/lib/braintree/venmo_account.rb +1 -1
  65. data/lib/braintree/version.rb +1 -1
  66. data/lib/braintree/visa_checkout_card.rb +2 -2
  67. data/lib/braintree/webhook_notification.rb +30 -20
  68. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  69. data/lib/braintree/webhook_testing_gateway.rb +30 -0
  70. data/lib/braintree/xml/generator.rb +5 -4
  71. data/lib/braintree/xml/libxml.rb +0 -1
  72. data/lib/braintree/xml/parser.rb +22 -12
  73. data/lib/braintree/xml/rexml.rb +70 -0
  74. data/spec/integration/braintree/add_on_spec.rb +1 -1
  75. data/spec/integration/braintree/address_spec.rb +28 -24
  76. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  77. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  78. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  79. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  80. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  81. data/spec/integration/braintree/credit_card_spec.rb +213 -122
  82. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  83. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  84. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  85. data/spec/integration/braintree/customer_spec.rb +282 -165
  86. data/spec/integration/braintree/dispute_search_spec.rb +28 -3
  87. data/spec/integration/braintree/dispute_spec.rb +6 -6
  88. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  89. data/spec/integration/braintree/http_spec.rb +2 -2
  90. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  91. data/spec/integration/braintree/merchant_spec.rb +14 -14
  92. data/spec/integration/braintree/oauth_spec.rb +11 -11
  93. data/spec/integration/braintree/payment_method_nonce_spec.rb +28 -35
  94. data/spec/integration/braintree/payment_method_spec.rb +269 -165
  95. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
  96. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  97. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  98. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  99. data/spec/integration/braintree/subscription_spec.rb +133 -133
  100. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  101. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  102. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  103. data/spec/integration/braintree/transaction_spec.rb +574 -360
  104. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
  105. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  106. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  107. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  108. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  109. data/spec/integration/spec_helper.rb +9 -3
  110. data/spec/oauth_test_helper.rb +1 -1
  111. data/spec/script/httpsd.rb +6 -6
  112. data/spec/spec_helper.rb +6 -3
  113. data/spec/unit/braintree/address_spec.rb +1 -1
  114. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  115. data/spec/unit/braintree/client_token_spec.rb +2 -2
  116. data/spec/unit/braintree/configuration_spec.rb +42 -42
  117. data/spec/unit/braintree/credit_card_spec.rb +13 -13
  118. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  119. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  120. data/spec/unit/braintree/customer_spec.rb +20 -10
  121. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  122. data/spec/unit/braintree/dispute_search_spec.rb +1 -0
  123. data/spec/unit/braintree/dispute_spec.rb +34 -9
  124. data/spec/unit/braintree/error_result_spec.rb +5 -5
  125. data/spec/unit/braintree/errors_spec.rb +8 -8
  126. data/spec/unit/braintree/http_spec.rb +5 -5
  127. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  128. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  129. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  130. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  131. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  132. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  133. data/spec/unit/braintree/resource_collection_spec.rb +9 -9
  134. data/spec/unit/braintree/risk_data_spec.rb +9 -5
  135. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  136. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  137. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  138. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  139. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  140. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  141. data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
  142. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  143. data/spec/unit/braintree/transaction_spec.rb +25 -17
  144. data/spec/unit/braintree/util_spec.rb +18 -18
  145. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  146. data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
  147. data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
  148. data/spec/unit/braintree/xml_spec.rb +31 -31
  149. metadata +16 -8
  150. 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
@@ -611,6 +611,22 @@ describe Braintree::WebhookNotification do
611
611
  metadata.token.should == "venmo_token"
612
612
  metadata.revoked_payment_method.class.should == Braintree::VenmoAccount
613
613
  end
614
+
615
+ it "builds a sample notification for a GrantedPaymentMethodRevoked webhook" do
616
+ sample_notification = Braintree::WebhookTesting.sample_notification(
617
+ Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked,
618
+ "my_id",
619
+ )
620
+
621
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
622
+ expect(notification.kind).to eq Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked
623
+
624
+ metadata = notification.revoked_payment_method_metadata
625
+
626
+ expect(metadata.customer_id).to eq "venmo_customer_id"
627
+ expect(metadata.token).to eq "my_id"
628
+ expect(metadata.revoked_payment_method.class).to eq Braintree::VenmoAccount
629
+ end
614
630
  end
615
631
  end
616
632
 
@@ -618,7 +634,7 @@ describe Braintree::WebhookNotification do
618
634
  it "builds a sample notification for a payment_method_revoked_by_customer webhook" do
619
635
  sample_notification = Braintree::WebhookTesting.sample_notification(
620
636
  Braintree::WebhookNotification::Kind::PaymentMethodRevokedByCustomer,
621
- "my_payment_method_token"
637
+ "my_payment_method_token",
622
638
  )
623
639
 
624
640
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -635,7 +651,7 @@ describe Braintree::WebhookNotification do
635
651
  it "builds a sample notification for a local_payment webhook" do
636
652
  sample_notification = Braintree::WebhookTesting.sample_notification(
637
653
  Braintree::WebhookNotification::Kind::LocalPaymentCompleted,
638
- "my_id"
654
+ "my_id",
639
655
  )
640
656
 
641
657
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
@@ -652,6 +668,22 @@ describe Braintree::WebhookNotification do
652
668
  end
653
669
  end
654
670
 
671
+
672
+ context "local_payment_reversed" do
673
+ it "builds a sample notification for a local_payment webhook" do
674
+ sample_notification = Braintree::WebhookTesting.sample_notification(
675
+ Braintree::WebhookNotification::Kind::LocalPaymentReversed,
676
+ "my_id",
677
+ )
678
+
679
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
680
+ notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentReversed
681
+
682
+ local_payment_reversed = notification.local_payment_reversed
683
+ local_payment_reversed.payment_id.should == "PAY-XYZ123"
684
+ end
685
+ end
686
+
655
687
  describe "parse" do
656
688
  it "raises InvalidSignature error when the signature is nil" do
657
689
  expect do
@@ -668,7 +700,7 @@ describe Braintree::WebhookNotification do
668
700
  it "raises InvalidSignature error when the signature is completely invalid" do
669
701
  sample_notification = Braintree::WebhookTesting.sample_notification(
670
702
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
671
- "my_id"
703
+ "my_id",
672
704
  )
673
705
 
674
706
  expect do
@@ -679,13 +711,13 @@ describe Braintree::WebhookNotification do
679
711
  it "raises InvalidSignature error with a message when the public key is not found" do
680
712
  sample_notification = Braintree::WebhookTesting.sample_notification(
681
713
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
682
- "my_id"
714
+ "my_id",
683
715
  )
684
716
 
685
717
  config = Braintree::Configuration.new(
686
- :merchant_id => 'merchant_id',
687
- :public_key => 'wrong_public_key',
688
- :private_key => 'wrong_private_key'
718
+ :merchant_id => "merchant_id",
719
+ :public_key => "wrong_public_key",
720
+ :private_key => "wrong_private_key",
689
721
  )
690
722
  gateway = Braintree::Gateway.new(config)
691
723
 
@@ -697,7 +729,7 @@ describe Braintree::WebhookNotification do
697
729
  it "raises InvalidSignature error if the payload has been changed" do
698
730
  sample_notification = Braintree::WebhookTesting.sample_notification(
699
731
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
700
- "my_id"
732
+ "my_id",
701
733
  )
702
734
 
703
735
  expect do
@@ -708,7 +740,7 @@ describe Braintree::WebhookNotification do
708
740
  it "raises InvalidSignature error with a message complaining about invalid characters" do
709
741
  sample_notification = Braintree::WebhookTesting.sample_notification(
710
742
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
711
- "my_id"
743
+ "my_id",
712
744
  )
713
745
 
714
746
  expect do
@@ -719,7 +751,7 @@ describe Braintree::WebhookNotification do
719
751
  it "allows all valid characters" do
720
752
  sample_notification = Braintree::WebhookTesting.sample_notification(
721
753
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
722
- "my_id"
754
+ "my_id",
723
755
  )
724
756
 
725
757
  sample_notification[:bt_payload] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+=/\n"
@@ -736,7 +768,7 @@ describe Braintree::WebhookNotification do
736
768
  it "retries a payload with a newline" do
737
769
  sample_notification = Braintree::WebhookTesting.sample_notification(
738
770
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
739
- "my_id"
771
+ "my_id",
740
772
  )
741
773
 
742
774
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
@@ -751,7 +783,7 @@ describe Braintree::WebhookNotification do
751
783
  it "returns true for check webhook kinds" do
752
784
  sample_notification = Braintree::WebhookTesting.sample_notification(
753
785
  Braintree::WebhookNotification::Kind::Check,
754
- nil
786
+ nil,
755
787
  )
756
788
 
757
789
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
@@ -762,7 +794,7 @@ describe Braintree::WebhookNotification do
762
794
  it "returns false for non-check webhook kinds" do
763
795
  sample_notification = Braintree::WebhookTesting.sample_notification(
764
796
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
765
- nil
797
+ nil,
766
798
  )
767
799
 
768
800
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)