braintree 2.104.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -23
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +11 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/base_module.rb +6 -0
  11. data/lib/braintree/bin_data.rb +9 -2
  12. data/lib/braintree/client_token.rb +1 -1
  13. data/lib/braintree/configuration.rb +12 -12
  14. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  15. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  16. data/lib/braintree/credit_card.rb +2 -77
  17. data/lib/braintree/credit_card_gateway.rb +17 -36
  18. data/lib/braintree/credit_card_verification.rb +18 -5
  19. data/lib/braintree/credit_card_verification_search.rb +1 -1
  20. data/lib/braintree/customer.rb +9 -78
  21. data/lib/braintree/customer_gateway.rb +2 -23
  22. data/lib/braintree/customer_search.rb +1 -1
  23. data/lib/braintree/disbursement.rb +1 -1
  24. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  25. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  26. data/lib/braintree/dispute.rb +32 -8
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +6 -3
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/enriched_customer_data.rb +21 -0
  31. data/lib/braintree/error_codes.rb +150 -171
  32. data/lib/braintree/exceptions.rb +5 -3
  33. data/lib/braintree/exchange_rate.rb +13 -0
  34. data/lib/braintree/exchange_rate_quote.rb +24 -0
  35. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  36. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  37. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  38. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  39. data/lib/braintree/gateway.rb +4 -14
  40. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
  41. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  42. data/lib/braintree/graphql_client.rb +7 -7
  43. data/lib/braintree/http.rb +4 -3
  44. data/lib/braintree/local_payment_completed.rb +2 -2
  45. data/lib/braintree/local_payment_expired.rb +21 -0
  46. data/lib/braintree/local_payment_funded.rb +22 -0
  47. data/lib/braintree/local_payment_reversed.rb +19 -0
  48. data/lib/braintree/merchant.rb +1 -1
  49. data/lib/braintree/merchant_account.rb +1 -1
  50. data/lib/braintree/merchant_account_gateway.rb +3 -1
  51. data/lib/braintree/merchant_gateway.rb +1 -1
  52. data/lib/braintree/modification.rb +1 -1
  53. data/lib/braintree/oauth_credentials.rb +1 -1
  54. data/lib/braintree/oauth_gateway.rb +5 -5
  55. data/lib/braintree/payment_instrument_type.rb +10 -14
  56. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  57. data/lib/braintree/payment_method_gateway.rb +15 -17
  58. data/lib/braintree/payment_method_nonce.rb +7 -4
  59. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  60. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  61. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  62. data/lib/braintree/payment_method_parser.rb +1 -8
  63. data/lib/braintree/plan.rb +21 -1
  64. data/lib/braintree/plan_gateway.rb +100 -0
  65. data/lib/braintree/processor_response_types.rb +3 -3
  66. data/lib/braintree/resource_collection.rb +8 -3
  67. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  68. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  69. data/lib/braintree/risk_data.rb +5 -1
  70. data/lib/braintree/samsung_pay_card.rb +1 -1
  71. data/lib/braintree/settlement_batch_summary.rb +2 -2
  72. data/lib/braintree/subscription.rb +11 -11
  73. data/lib/braintree/successful_result.rb +3 -2
  74. data/lib/braintree/test/credit_card.rb +1 -0
  75. data/lib/braintree/test/nonce.rb +4 -23
  76. data/lib/braintree/three_d_secure_info.rb +22 -12
  77. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  78. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  79. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  80. data/lib/braintree/transaction/installment.rb +28 -0
  81. data/lib/braintree/transaction/paypal_details.rb +3 -0
  82. data/lib/braintree/transaction/subscription_details.rb +2 -0
  83. data/lib/braintree/transaction.rb +65 -120
  84. data/lib/braintree/transaction_gateway.rb +39 -27
  85. data/lib/braintree/transaction_line_item.rb +1 -1
  86. data/lib/braintree/transaction_review.rb +18 -0
  87. data/lib/braintree/transaction_search.rb +5 -3
  88. data/lib/braintree/unknown_payment_method.rb +1 -1
  89. data/lib/braintree/us_bank_account.rb +3 -3
  90. data/lib/braintree/us_bank_account_verification.rb +1 -1
  91. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  92. data/lib/braintree/util.rb +21 -6
  93. data/lib/braintree/venmo_account.rb +1 -1
  94. data/lib/braintree/venmo_profile_data.rb +23 -0
  95. data/lib/braintree/version.rb +2 -2
  96. data/lib/braintree/visa_checkout_card.rb +2 -2
  97. data/lib/braintree/webhook_notification.rb +44 -30
  98. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  99. data/lib/braintree/webhook_testing_gateway.rb +104 -43
  100. data/lib/braintree/xml/generator.rb +5 -4
  101. data/lib/braintree/xml/parser.rb +22 -35
  102. data/lib/braintree/xml/rexml.rb +4 -5
  103. data/lib/braintree.rb +28 -23
  104. data/spec/integration/braintree/add_on_spec.rb +1 -1
  105. data/spec/integration/braintree/address_spec.rb +30 -113
  106. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  107. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  108. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  109. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  110. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  111. data/spec/integration/braintree/credit_card_spec.rb +219 -593
  112. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  113. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  114. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  115. data/spec/integration/braintree/customer_spec.rb +484 -513
  116. data/spec/integration/braintree/dispute_search_spec.rb +35 -6
  117. data/spec/integration/braintree/dispute_spec.rb +6 -7
  118. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  119. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  120. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  121. data/spec/integration/braintree/http_spec.rb +2 -2
  122. data/spec/integration/braintree/merchant_account_spec.rb +28 -29
  123. data/spec/integration/braintree/merchant_spec.rb +14 -14
  124. data/spec/integration/braintree/oauth_spec.rb +11 -11
  125. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
  126. data/spec/integration/braintree/payment_method_spec.rb +535 -270
  127. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  128. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  129. data/spec/integration/braintree/plan_spec.rb +82 -0
  130. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  131. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  132. data/spec/integration/braintree/subscription_spec.rb +144 -149
  133. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  134. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  135. data/spec/integration/braintree/transaction_search_spec.rb +175 -70
  136. data/spec/integration/braintree/transaction_spec.rb +955 -894
  137. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  138. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  139. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  140. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  141. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  142. data/spec/integration/spec_helper.rb +16 -7
  143. data/spec/oauth_test_helper.rb +1 -1
  144. data/spec/script/httpsd.rb +6 -6
  145. data/spec/spec_helper.rb +8 -14
  146. data/spec/unit/braintree/address_spec.rb +1 -9
  147. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
  148. data/spec/unit/braintree/client_token_spec.rb +2 -2
  149. data/spec/unit/braintree/configuration_spec.rb +42 -42
  150. data/spec/unit/braintree/credit_card_spec.rb +13 -32
  151. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  152. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  153. data/spec/unit/braintree/customer_spec.rb +21 -22
  154. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  155. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  156. data/spec/unit/braintree/dispute_spec.rb +75 -21
  157. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  158. data/spec/unit/braintree/error_result_spec.rb +5 -5
  159. data/spec/unit/braintree/errors_spec.rb +8 -8
  160. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  161. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  162. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  163. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  164. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  165. data/spec/unit/braintree/http_spec.rb +10 -8
  166. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  167. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  168. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  169. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  170. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  171. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  172. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  173. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  174. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  175. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  176. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  177. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  178. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  179. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  180. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  181. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  182. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  183. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  184. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  185. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  186. data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
  187. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  188. data/spec/unit/braintree/transaction_spec.rb +36 -54
  189. data/spec/unit/braintree/util_spec.rb +55 -21
  190. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  191. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  192. data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
  193. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  194. data/spec/unit/braintree/xml_spec.rb +31 -31
  195. metadata +62 -30
  196. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  197. data/lib/braintree/coinbase_account.rb +0 -34
  198. data/lib/braintree/europe_bank_account.rb +0 -36
  199. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  200. data/lib/braintree/ideal_payment.rb +0 -61
  201. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  202. data/lib/braintree/masterpass_card.rb +0 -83
  203. data/lib/braintree/settlement_batch.rb +0 -0
  204. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  205. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  206. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  207. data/lib/braintree/transparent_redirect.rb +0 -40
  208. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  209. data/spec/hacks/tcp_socket.rb +0 -18
  210. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  211. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  212. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  213. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -7,6 +7,7 @@ describe Braintree::Dispute do
7
7
  :amount => "31.00",
8
8
  :amount_disputed => "500.00",
9
9
  :amount_won => "0.00",
10
+ :chargeback_protection_level => nil,
10
11
  :created_at => Time.utc(2009, 3, 9, 10, 50, 39),
11
12
  :processor_comments => "forwarded comments",
12
13
  :date_opened => "2009-03-09",
@@ -46,7 +47,14 @@ describe Braintree::Dispute do
46
47
  :order_id => nil,
47
48
  :purchase_order_number => "po",
48
49
  :payment_instrument_subtype => "Visa",
49
- }
50
+ },
51
+ :paypal_messages => [
52
+ {
53
+ :message => "message",
54
+ :sender => "seller",
55
+ :sent_at => Time.utc(2009, 3, 9, 10, 50, 39),
56
+ }
57
+ ]
50
58
  }
51
59
  end
52
60
 
@@ -137,13 +145,13 @@ describe Braintree::Dispute do
137
145
  it "does not raise an exception if the optional parameters are valid" do
138
146
  Braintree::Http.stub(:new).and_return double.as_null_object
139
147
  expect do
140
- Braintree::Dispute.add_file_evidence("dispute_id", { category: "GENERAL", document_id: "document_id" })
148
+ Braintree::Dispute.add_file_evidence("dispute_id", {category: "GENERAL", document_id: "document_id"})
141
149
  end.to_not raise_error
142
150
  end
143
151
 
144
152
  it "raises an exception if the optional params contain invalid keys" do
145
153
  expect do
146
- Braintree::Dispute.add_file_evidence("dispute_id", { random_param: "" })
154
+ Braintree::Dispute.add_file_evidence("dispute_id", {random_param: ""})
147
155
  end.to raise_error(ArgumentError)
148
156
  end
149
157
 
@@ -151,7 +159,7 @@ describe Braintree::Dispute do
151
159
  Braintree::Http.stub(:new).and_return double.as_null_object
152
160
 
153
161
  expect do
154
- Braintree::Dispute.add_file_evidence("dispute_id", { category: 3, document_id: "document_id" })
162
+ Braintree::Dispute.add_file_evidence("dispute_id", {category: 3, document_id: "document_id"})
155
163
  end.to raise_error(ArgumentError)
156
164
  end
157
165
  end
@@ -200,38 +208,31 @@ describe Braintree::Dispute do
200
208
  it "does not raise an exception if the optional parameters are valid" do
201
209
  Braintree::Http.stub(:new).and_return double.as_null_object
202
210
  expect do
203
- Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", tag: "", sequence_number: 3 })
204
- end.to_not raise_error
205
- end
206
-
207
- it "does not raise an exception if the category parameter is provided" do
208
- Braintree::Http.stub(:new).and_return double.as_null_object
209
- expect do
210
- Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", category: "", sequence_number: 3 })
211
+ Braintree::Dispute.add_text_evidence("dispute_id", {content: "a", category: "", sequence_number: 3})
211
212
  end.to_not raise_error
212
213
  end
213
214
 
214
215
  it "raises an exception if the optional params contain invalid keys" do
215
216
  expect do
216
- Braintree::Dispute.add_text_evidence("dispute_id", { random_param: "" })
217
+ Braintree::Dispute.add_text_evidence("dispute_id", {random_param: ""})
217
218
  end.to raise_error(ArgumentError)
218
219
  end
219
220
 
220
221
  it "raises an exception if sequence_number is provided and not an integer" do
221
222
  expect do
222
- Braintree::Dispute.add_text_evidence("dispute_id", { sequence_number: "abc" })
223
+ Braintree::Dispute.add_text_evidence("dispute_id", {sequence_number: "abc"})
223
224
  end.to raise_error(ArgumentError)
224
225
  end
225
226
 
226
227
  it "raises an exception if the param tag is not a string" do
227
228
  expect do
228
- Braintree::Dispute.add_text_evidence("dispute_id", { tag: 3 })
229
+ Braintree::Dispute.add_text_evidence("dispute_id", {tag: 3})
229
230
  end.to raise_error(ArgumentError)
230
231
  end
231
232
 
232
233
  it "raises an exception if the param category is not a string" do
233
234
  expect do
234
- Braintree::Dispute.add_text_evidence("dispute_id", { category: 3 })
235
+ Braintree::Dispute.add_text_evidence("dispute_id", {category: 3})
235
236
  end.to raise_error(ArgumentError)
236
237
  end
237
238
  end
@@ -283,6 +284,45 @@ describe Braintree::Dispute do
283
284
  dispute.amount_won.should == 0.0
284
285
  end
285
286
 
287
+ it "returns 'Effortless Chargeback Protection tool' when initial chargeback_protection_level is effortless" do
288
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Effortless)
289
+ dispute = Braintree::Dispute._new(attributes)
290
+
291
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
292
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
293
+ end
294
+
295
+ it "returns 'Chargeback Protection tool' when initial chargeback_protection_level is standard" do
296
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Standard)
297
+ dispute = Braintree::Dispute._new(attributes)
298
+
299
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Standard)
300
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::StandardCBP)
301
+ end
302
+
303
+ it "returns 'No Protection' when initial chargeback_protection_level is nil" do
304
+ dispute = Braintree::Dispute._new(attributes)
305
+
306
+ expect(dispute.chargeback_protection_level).to eq(nil)
307
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
308
+ end
309
+
310
+ it "returns 'No Protection' when initial chargeback_protection_level is empty" do
311
+ attributes.merge!(:chargeback_protection_level => "")
312
+ dispute = Braintree::Dispute._new(attributes)
313
+
314
+ expect(dispute.chargeback_protection_level).to eq("")
315
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
316
+ end
317
+
318
+ it "returns 'No Protection' when initial chargeback_protection_level is not_protected" do
319
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
320
+ dispute = Braintree::Dispute._new(attributes)
321
+
322
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
323
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
324
+ end
325
+
286
326
  [
287
327
  :reply_by_date,
288
328
  :amount,
@@ -327,7 +367,7 @@ describe Braintree::Dispute do
327
367
  dispute.transaction.payment_instrument_subtype.should == "Visa"
328
368
  end
329
369
 
330
- it "converts status_history hash into an array of Dispute::HistoryEvent objects" do
370
+ it "converts status_history hash into an array of Dispute::StatusHistory objects" do
331
371
  dispute = Braintree::Dispute._new(attributes)
332
372
 
333
373
  dispute.status_history.length.should == 1
@@ -355,6 +395,16 @@ describe Braintree::Dispute do
355
395
  evidence2.url.should == nil
356
396
  end
357
397
 
398
+ it "converts paypal_messages hash into an array of Dispute::PayPalMessage objects" do
399
+ dispute = Braintree::Dispute._new(attributes)
400
+
401
+ dispute.paypal_messages.length.should == 1
402
+ paypal_message_1 = dispute.paypal_messages.first
403
+ paypal_message_1.message.should == "message"
404
+ paypal_message_1.sender.should == "seller"
405
+ paypal_message_1.sent_at.should == Time.utc(2009, 3, 9, 10, 50, 39)
406
+ end
407
+
358
408
  it "handles nil evidence" do
359
409
  attributes.delete(:evidence)
360
410
 
@@ -363,6 +413,14 @@ describe Braintree::Dispute do
363
413
  dispute.evidence.should == nil
364
414
  end
365
415
 
416
+ it "handles nil paypal_messages" do
417
+ attributes.delete(:paypal_messages)
418
+
419
+ dispute = Braintree::Dispute._new(attributes)
420
+
421
+ dispute.paypal_messages.should == nil
422
+ end
423
+
366
424
  it "sets the older webhook fields for backwards compatibility" do
367
425
  dispute = Braintree::Dispute._new(attributes)
368
426
 
@@ -398,10 +456,6 @@ describe Braintree::Dispute do
398
456
  describe "comments" do
399
457
  let(:dispute) { Braintree::Dispute._new(attributes) }
400
458
 
401
- it "#forwarded_comments returns `processor_comments`" do
402
- expect(dispute.forwarded_comments).to eq(dispute.processor_comments)
403
- end
404
-
405
459
  it "#processor_comments" do
406
460
  expect(dispute.processor_comments).to eq(attributes[:processor_comments])
407
461
  end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::EnrichedCustomerData do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::EnrichedCustomerData.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+
15
+ params = {
16
+ fields_updated: ["username"],
17
+ profile_data: {
18
+ username: "a-username",
19
+ first_name: "a-first-name",
20
+ last_name: "a-last-name",
21
+ phone_number: "a-phone-number",
22
+ email: "a-email",
23
+ },
24
+ }
25
+
26
+ payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)
27
+
28
+ payment_method_customer_data_updated.profile_data.should be_a(Braintree::VenmoProfileData)
29
+ payment_method_customer_data_updated.fields_updated.should eq(["username"])
30
+ end
31
+ end
32
+ end
@@ -10,7 +10,7 @@ describe Braintree::ErrorResult do
10
10
  :params => "params",
11
11
  :errors => {:errors => []},
12
12
  :extra => "is ignored",
13
- :message => "foo bar"
13
+ :message => "foo bar",
14
14
  )
15
15
  end.to_not raise_error
16
16
  end
@@ -36,7 +36,7 @@ describe Braintree::ErrorResult do
36
36
  :params => "params",
37
37
  :errors => {},
38
38
  :verification => {},
39
- :transaction => nil
39
+ :transaction => nil,
40
40
  )
41
41
  result.inspect.should include("credit_card_verification: #<Braintree::CreditCardVerification status: ")
42
42
  end
@@ -47,7 +47,7 @@ describe Braintree::ErrorResult do
47
47
  :params => "params",
48
48
  :errors => {},
49
49
  :verification => nil,
50
- :transaction => nil
50
+ :transaction => nil,
51
51
  )
52
52
  result.inspect.should_not include("credit_card_verification")
53
53
  end
@@ -58,7 +58,7 @@ describe Braintree::ErrorResult do
58
58
  :params => "params",
59
59
  :errors => {},
60
60
  :verification => nil,
61
- :transaction => {}
61
+ :transaction => {},
62
62
  )
63
63
  result.inspect.should include("transaction: #<Braintree::Transaction id: ")
64
64
  end
@@ -69,7 +69,7 @@ describe Braintree::ErrorResult do
69
69
  :params => "params",
70
70
  :errors => {},
71
71
  :verification => nil,
72
- :transaction => nil
72
+ :transaction => nil,
73
73
  )
74
74
  result.inspect.should_not include("transaction")
75
75
  end
@@ -4,7 +4,7 @@ describe Braintree::Errors do
4
4
  describe "for" do
5
5
  it "accesses errors for the given scope" do
6
6
  errors = Braintree::Errors.new(
7
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
7
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
8
8
  )
9
9
  errors.for(:level1).size.should == 1
10
10
  errors.for(:level1)[0].code.should == "code1"
@@ -12,7 +12,7 @@ describe Braintree::Errors do
12
12
 
13
13
  it "returns nil if there are no errors at the given scope" do
14
14
  errors = Braintree::Errors.new(
15
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
15
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
16
16
  )
17
17
  errors.for(:no_errors_here).should == nil
18
18
  end
@@ -21,7 +21,7 @@ describe Braintree::Errors do
21
21
  describe "inspect" do
22
22
  it "is better than the default inspect" do
23
23
  errors = Braintree::Errors.new(
24
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
24
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
25
25
  )
26
26
  errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
27
27
  end
@@ -33,7 +33,7 @@ describe Braintree::Errors do
33
33
  :level2 => {
34
34
  :errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}],
35
35
  }
36
- }
36
+ },
37
37
  )
38
38
  errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
39
39
  end
@@ -48,7 +48,7 @@ describe Braintree::Errors do
48
48
  :errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}],
49
49
  }
50
50
  }
51
- }
51
+ },
52
52
  )
53
53
  errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
54
54
  end
@@ -65,7 +65,7 @@ describe Braintree::Errors do
65
65
  {:code => "3", :attribute => "attr3", :message => "message3"}
66
66
  ],
67
67
  }
68
- }
68
+ },
69
69
  )
70
70
  errors.map { |e| e.code }.sort.should == %w[1 2 3]
71
71
  end
@@ -74,7 +74,7 @@ describe Braintree::Errors do
74
74
  describe "size" do
75
75
  it "returns the number of validation errors at the first level if only has one level" do
76
76
  errors = Braintree::Errors.new(
77
- :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}
77
+ :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
78
78
  )
79
79
  errors.size.should == 1
80
80
  end
@@ -89,7 +89,7 @@ describe Braintree::Errors do
89
89
  {:code => "3", :attribute => "attr3", :message => "message3"}
90
90
  ],
91
91
  }
92
- }
92
+ },
93
93
  )
94
94
  errors.size.should == 3
95
95
  end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteInput do
4
+ let(:exchange_rate_quote_input) do
5
+ {
6
+ base_currency: "USD",
7
+ quote_currency: "EUR",
8
+ base_amount: "10.00",
9
+ markup: "2.00"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the input keys to attrs variable" do
15
+ quote_input = described_class.new(exchange_rate_quote_input)
16
+
17
+ expect(quote_input.attrs).to include(:base_currency)
18
+ expect(quote_input.attrs).to include(:quote_currency)
19
+ expect(quote_input.attrs).to include(:base_amount)
20
+ expect(quote_input.attrs).to include(:markup)
21
+ expect(quote_input.attrs.length).to eq(4)
22
+ end
23
+ end
24
+
25
+ describe "inspect" do
26
+ it "includes the base_currency first" do
27
+ output = described_class.new(base_currency: "USD").inspect
28
+
29
+ expect(output).to include("#<Braintree::ExchangeRateQuoteInput base_currency:\"USD\">")
30
+ end
31
+
32
+ it "includes all quote input attributes" do
33
+ quote_input = described_class.new(exchange_rate_quote_input)
34
+ output = quote_input.inspect
35
+
36
+ expect(output).to include("base_currency:\"USD\"")
37
+ expect(output).to include("quote_currency:\"EUR\"")
38
+ expect(output).to include("base_amount:\"10.00\"")
39
+ expect(output).to include("markup:\"2.00\"")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteRequest do
4
+ describe "#initialize" do
5
+ it "creates and validates the exchange rate quote request" do
6
+ req = Braintree::ExchangeRateQuoteRequest.new(
7
+ :quotes => [
8
+ {
9
+ :base_currency => "USD",
10
+ :quote_currency => "EUR",
11
+ :base_amount => "10.00",
12
+ :markup => "2.00"
13
+ },
14
+ {
15
+ :base_currency => "EUR",
16
+ :quote_currency => "GBP",
17
+ :base_amount => "20.00",
18
+ :markup => "4.00"
19
+ }
20
+ ],
21
+ )
22
+
23
+ expect(req.quotes[0].base_currency).to eq("USD")
24
+ expect(req.quotes[0].quote_currency).to eq("EUR")
25
+ expect(req.quotes[0].base_amount).to eq("10.00")
26
+ expect(req.quotes[0].markup).to eq("2.00")
27
+
28
+ expect(req.quotes[1].base_currency).to eq("EUR")
29
+ expect(req.quotes[1].quote_currency).to eq("GBP")
30
+ expect(req.quotes[1].base_amount).to eq("20.00")
31
+ expect(req.quotes[1].markup).to eq("4.00")
32
+ end
33
+
34
+ it "creates and validates the exchange rate quote request without amount and markup" do
35
+ req = Braintree::ExchangeRateQuoteRequest.new(
36
+ :quotes => [
37
+ {
38
+ :base_currency => "USD",
39
+ :quote_currency => "EUR",
40
+ },
41
+ {
42
+ :base_currency => "EUR",
43
+ :quote_currency => "GBP",
44
+ }
45
+ ],
46
+ )
47
+
48
+ expect(req.quotes[0].base_currency).to eq("USD")
49
+ expect(req.quotes[0].quote_currency).to eq("EUR")
50
+ expect(req.quotes[0].base_amount).to be_nil
51
+ expect(req.quotes[0].markup).to be_nil
52
+
53
+ expect(req.quotes[1].base_currency).to eq("EUR")
54
+ expect(req.quotes[1].quote_currency).to eq("GBP")
55
+ expect(req.quotes[1].base_amount).to be_nil
56
+ expect(req.quotes[1].markup).to be_nil
57
+ end
58
+
59
+ end
60
+
61
+ describe "inspect" do
62
+ it "prints the attributes" do
63
+ exchange_rate_req = Braintree::ExchangeRateQuoteRequest.new(
64
+ :quotes => [
65
+ {
66
+ :base_currency => "USD",
67
+ :quote_currency => "EUR",
68
+ :base_amount => "10.00",
69
+ :markup => "2.00"
70
+ },
71
+ {
72
+ :base_currency => "EUR",
73
+ :quote_currency => "GBP",
74
+ :base_amount => "20.00",
75
+ :markup => "4.00"
76
+ }
77
+ ],
78
+ )
79
+ expect(exchange_rate_req.inspect).to eq(%(#<Braintree::ExchangeRateQuoteRequest quotes:[#<Braintree::ExchangeRateQuoteInput base_currency:"USD" quote_currency:"EUR" base_amount:"10.00" markup:"2.00">, #<Braintree::ExchangeRateQuoteInput base_currency:"EUR" quote_currency:"GBP" base_amount:"20.00" markup:"4.00">]>))
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteResponse do
4
+ describe "#initialize" do
5
+ it "creates and validated the exchange rate quote payload" do
6
+ quote_payload = Braintree::ExchangeRateQuoteResponse.new(
7
+ quotes: [
8
+ {
9
+ :base_amount => "10.00",
10
+ :quote_amount => "9.03",
11
+ :exchange_rate => "0.90"
12
+ },
13
+ {
14
+ :base_amount => "20.00",
15
+ :quote_amount => "18.06",
16
+ :exchange_rate => "0.90"
17
+ }
18
+ ],
19
+ )
20
+
21
+ quote_1 = quote_payload.quotes[0]
22
+ quote_2 = quote_payload.quotes[1]
23
+
24
+ expect(quote_1.base_amount).to eq("10.00")
25
+ expect(quote_1.quote_amount).to eq("9.03")
26
+ expect(quote_1.exchange_rate).to eq("0.90")
27
+
28
+ expect(quote_2.base_amount).to eq("20.00")
29
+ expect(quote_2.quote_amount).to eq("18.06")
30
+ expect(quote_1.exchange_rate).to eq("0.90")
31
+ end
32
+ end
33
+
34
+ describe "inspect" do
35
+ it "prints the attributes" do
36
+ exchange_rate_quote_payload = Braintree::ExchangeRateQuoteResponse.new(
37
+ quotes: [
38
+ {
39
+ :base_amount => "10.00",
40
+ :quote_amount => "9.03"
41
+ },
42
+ {
43
+ :base_amount => "20.00",
44
+ :quote_amount => "18.06"
45
+ }
46
+ ],
47
+ )
48
+
49
+ expect(exchange_rate_quote_payload.inspect).to eq(%(#<Braintree::ExchangeRateQuoteResponse quotes:[#<Braintree::ExchangeRateQuote base_amount:"10.00" quote_amount:"9.03">, #<Braintree::ExchangeRateQuote base_amount:"20.00" quote_amount:"18.06">]>))
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuote do
4
+ let(:rate_quote) do
5
+ {
6
+ id: "1234",
7
+ base_amount: "10.00",
8
+ exchange_rate: "74",
9
+ quote_amount: "740"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the input keys to attrs variable" do
15
+ quote = described_class.new(rate_quote)
16
+
17
+ expect(quote.attrs).to include(:id)
18
+ expect(quote.attrs).to include(:base_amount)
19
+ expect(quote.attrs).to include(:exchange_rate)
20
+ expect(quote.attrs).to include(:quote_amount)
21
+ expect(quote.attrs.length).to eq(4)
22
+ end
23
+ end
24
+
25
+ describe "inspect" do
26
+ it "includes the id first" do
27
+ output = described_class.new(id: "1234").inspect
28
+
29
+ expect(output).to include("#<Braintree::ExchangeRateQuote id:\"1234\">")
30
+ end
31
+
32
+ it "includes all quote attributes" do
33
+ quote = described_class.new(rate_quote)
34
+ output = quote.inspect
35
+
36
+ expect(output).to include("id:\"1234\"")
37
+ expect(output).to include("base_amount:\"10.00\"")
38
+ expect(output).to include("exchange_rate:\"74\"")
39
+ expect(output).to include("quote_amount:\"740\"")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe ::Braintree::ExchangeRate do
4
+ let(:rate_quote) do
5
+ {
6
+ id: "1234",
7
+ base_amount: "10.00",
8
+ exchange_rate: "74",
9
+ quote_amount: "740"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the attributes" do
15
+ exchange_rate = described_class.new(:gateway, rate_quote).inspect
16
+
17
+ expect(exchange_rate).to include("@id=\"1234\"")
18
+ expect(exchange_rate).to include("@base_amount=\"10.00\"")
19
+ expect(exchange_rate).to include("@exchange_rate=\"74\"")
20
+ expect(exchange_rate).to include("@quote_amount=\"740\"")
21
+ end
22
+ end
23
+ end
@@ -25,6 +25,7 @@ END
25
25
  <last-name>Doe</last-name>
26
26
  <number>1234560000001234</number>
27
27
  <cvv>123</cvv>
28
+ <encrypted-card-data>8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881</encrypted-card-data>
28
29
  </customer>
29
30
  END
30
31
 
@@ -34,6 +35,7 @@ END
34
35
  [Braintree] <last-name>Doe</last-name>
35
36
  [Braintree] <number>123456******1234</number>
36
37
  [Braintree] <cvv>***</cvv>
38
+ [Braintree] <encrypted-card-data>***</encrypted-card-data>
37
39
  [Braintree] </customer>
38
40
  END
39
41
  Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
@@ -67,7 +69,7 @@ END
67
69
  :proxy_address => "localhost",
68
70
  :proxy_port => 8080,
69
71
  :proxy_user => "user",
70
- :proxy_pass => "test"
72
+ :proxy_pass => "test",
71
73
  )
72
74
 
73
75
  http = Braintree::Http.new(config)
@@ -75,7 +77,7 @@ END
75
77
  "Net::HTTP",
76
78
  :open_timeout= => nil,
77
79
  :read_timeout= => nil,
78
- :start => nil
80
+ :start => nil,
79
81
  )
80
82
 
81
83
  Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
@@ -86,7 +88,7 @@ END
86
88
  it "accepts a partially specified proxy" do
87
89
  config = Braintree::Configuration.new(
88
90
  :proxy_address => "localhost",
89
- :proxy_port => 8080
91
+ :proxy_port => 8080,
90
92
  )
91
93
 
92
94
  http = Braintree::Http.new(config)
@@ -94,7 +96,7 @@ END
94
96
  "Net::HTTP",
95
97
  :open_timeout= => nil,
96
98
  :read_timeout= => nil,
97
- :start => nil
99
+ :start => nil,
98
100
  )
99
101
 
100
102
  Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
@@ -109,7 +111,7 @@ END
109
111
  "Net::HTTP",
110
112
  :open_timeout= => nil,
111
113
  :read_timeout= => nil,
112
- :start => nil
114
+ :start => nil,
113
115
  )
114
116
 
115
117
  Net::HTTP.should_receive(:new).with(nil, nil).and_return(net_http_instance)
@@ -130,7 +132,7 @@ END
130
132
  expect(default_headers["Accept-Encoding"]).to eq("gzip")
131
133
  expect(default_headers["Content-Type"]).to eq("application/xml")
132
134
  expect(default_headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
133
- expect(default_headers["X-ApiVersion"]).to eq("5")
135
+ expect(default_headers["X-ApiVersion"]).to eq("6")
134
136
  end
135
137
 
136
138
  it "overwrites defaults with override headers" do
@@ -144,7 +146,7 @@ END
144
146
  expect(headers["Authorization"]).to eq("token")
145
147
  expect(headers["Content-Type"]).to eq("application/xml")
146
148
  expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
147
- expect(headers["X-ApiVersion"]).to eq("5")
149
+ expect(headers["X-ApiVersion"]).to eq("6")
148
150
  end
149
151
 
150
152
  it "extends default headers when new headers are specified" do
@@ -156,7 +158,7 @@ END
156
158
  expect(headers["Accept-Encoding"]).to eq("gzip")
157
159
  expect(headers["Content-Type"]).to eq("application/xml")
158
160
  expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
159
- expect(headers["X-ApiVersion"]).to eq("5")
161
+ expect(headers["X-ApiVersion"]).to eq("6")
160
162
  expect(headers["New-Header"]).to eq("New Value")
161
163
  end
162
164
  end