braintree 4.14.0 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/account_updater_daily_report.rb +3 -3
  3. data/lib/braintree/ach_mandate.rb +1 -1
  4. data/lib/braintree/add_on_gateway.rb +1 -1
  5. data/lib/braintree/address.rb +4 -4
  6. data/lib/braintree/address_gateway.rb +5 -5
  7. data/lib/braintree/advanced_search.rb +10 -10
  8. data/lib/braintree/apple_pay.rb +3 -3
  9. data/lib/braintree/apple_pay_card.rb +3 -3
  10. data/lib/braintree/apple_pay_options.rb +3 -3
  11. data/lib/braintree/authorization_adjustment.rb +3 -3
  12. data/lib/braintree/base_module.rb +1 -1
  13. data/lib/braintree/bin_data.rb +2 -2
  14. data/lib/braintree/client_token_gateway.rb +1 -1
  15. data/lib/braintree/configuration.rb +22 -22
  16. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  17. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  18. data/lib/braintree/credit_card.rb +22 -9
  19. data/lib/braintree/credit_card_gateway.rb +23 -11
  20. data/lib/braintree/credit_card_verification.rb +3 -3
  21. data/lib/braintree/credit_card_verification_gateway.rb +28 -11
  22. data/lib/braintree/credit_card_verification_search.rb +1 -1
  23. data/lib/braintree/customer.rb +5 -9
  24. data/lib/braintree/customer_gateway.rb +7 -7
  25. data/lib/braintree/customer_search.rb +1 -1
  26. data/lib/braintree/descriptor.rb +1 -1
  27. data/lib/braintree/digest.rb +1 -1
  28. data/lib/braintree/disbursement.rb +5 -5
  29. data/lib/braintree/discount_gateway.rb +1 -1
  30. data/lib/braintree/dispute/evidence.rb +1 -1
  31. data/lib/braintree/dispute/paypal_message.rb +1 -1
  32. data/lib/braintree/dispute/status_history.rb +1 -1
  33. data/lib/braintree/dispute/transaction.rb +1 -1
  34. data/lib/braintree/dispute/transaction_details.rb +1 -1
  35. data/lib/braintree/dispute.rb +3 -3
  36. data/lib/braintree/dispute_gateway.rb +1 -1
  37. data/lib/braintree/dispute_search.rb +1 -1
  38. data/lib/braintree/document_upload.rb +2 -2
  39. data/lib/braintree/document_upload_gateway.rb +3 -3
  40. data/lib/braintree/enriched_customer_data.rb +2 -2
  41. data/lib/braintree/error_codes.rb +4 -0
  42. data/lib/braintree/error_result.rb +2 -3
  43. data/lib/braintree/errors.rb +3 -3
  44. data/lib/braintree/exceptions.rb +1 -2
  45. data/lib/braintree/exchange_rate.rb +2 -2
  46. data/lib/braintree/exchange_rate_quote.rb +3 -3
  47. data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
  48. data/lib/braintree/exchange_rate_quote_input.rb +3 -3
  49. data/lib/braintree/exchange_rate_quote_request.rb +3 -3
  50. data/lib/braintree/exchange_rate_quote_response.rb +3 -3
  51. data/lib/braintree/facilitated_details.rb +1 -1
  52. data/lib/braintree/facilitator_details.rb +1 -1
  53. data/lib/braintree/google_pay_card.rb +3 -3
  54. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  55. data/lib/braintree/graphql_client.rb +1 -1
  56. data/lib/braintree/http.rb +5 -5
  57. data/lib/braintree/local_payment_completed.rb +2 -2
  58. data/lib/braintree/local_payment_expired.rb +2 -2
  59. data/lib/braintree/local_payment_funded.rb +2 -2
  60. data/lib/braintree/local_payment_reversed.rb +2 -2
  61. data/lib/braintree/merchant.rb +3 -3
  62. data/lib/braintree/merchant_account.rb +2 -2
  63. data/lib/braintree/merchant_account_gateway.rb +9 -9
  64. data/lib/braintree/meta_checkout_card.rb +89 -0
  65. data/lib/braintree/meta_checkout_token.rb +88 -0
  66. data/lib/braintree/modification.rb +3 -3
  67. data/lib/braintree/oauth_credentials.rb +3 -3
  68. data/lib/braintree/paginated_collection.rb +2 -2
  69. data/lib/braintree/paginated_result.rb +1 -1
  70. data/lib/braintree/payment_instrument_type.rb +2 -0
  71. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
  72. data/lib/braintree/payment_method_gateway.rb +23 -10
  73. data/lib/braintree/payment_method_nonce.rb +4 -4
  74. data/lib/braintree/payment_method_nonce_details.rb +1 -1
  75. data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
  76. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  77. data/lib/braintree/paypal_account.rb +1 -2
  78. data/lib/braintree/paypal_account_gateway.rb +5 -5
  79. data/lib/braintree/plan.rb +1 -1
  80. data/lib/braintree/plan_gateway.rb +2 -2
  81. data/lib/braintree/resource_collection.rb +2 -2
  82. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  83. data/lib/braintree/risk_data.rb +1 -1
  84. data/lib/braintree/samsung_pay_card.rb +5 -5
  85. data/lib/braintree/sepa_direct_debit_account.rb +2 -2
  86. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
  87. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  88. data/lib/braintree/sha256_digest.rb +1 -1
  89. data/lib/braintree/subscription/status_details.rb +1 -1
  90. data/lib/braintree/subscription.rb +2 -2
  91. data/lib/braintree/subscription_gateway.rb +6 -6
  92. data/lib/braintree/subscription_search.rb +1 -1
  93. data/lib/braintree/successful_result.rb +2 -2
  94. data/lib/braintree/test/credit_card.rb +7 -10
  95. data/lib/braintree/test/merchant_account.rb +1 -1
  96. data/lib/braintree/test/nonce.rb +4 -0
  97. data/lib/braintree/test/transaction_amounts.rb +2 -3
  98. data/lib/braintree/test/venmo_sdk.rb +2 -0
  99. data/lib/braintree/testing_gateway.rb +1 -1
  100. data/lib/braintree/three_d_secure_info.rb +1 -1
  101. data/lib/braintree/transaction/address_details.rb +2 -1
  102. data/lib/braintree/transaction/credit_card_details.rb +4 -1
  103. data/lib/braintree/transaction/customer_details.rb +1 -1
  104. data/lib/braintree/transaction/disbursement_details.rb +1 -1
  105. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  106. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  107. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  108. data/lib/braintree/transaction/package_details.rb +16 -0
  109. data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
  110. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
  111. data/lib/braintree/transaction/status_details.rb +1 -1
  112. data/lib/braintree/transaction/subscription_details.rb +1 -1
  113. data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
  114. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  115. data/lib/braintree/transaction.rb +37 -20
  116. data/lib/braintree/transaction_gateway.rb +44 -15
  117. data/lib/braintree/transaction_line_item.rb +13 -10
  118. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  119. data/lib/braintree/transaction_review.rb +1 -1
  120. data/lib/braintree/transaction_search.rb +7 -6
  121. data/lib/braintree/unknown_payment_method.rb +1 -1
  122. data/lib/braintree/us_bank_account.rb +2 -2
  123. data/lib/braintree/us_bank_account_verification.rb +23 -15
  124. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  125. data/lib/braintree/util.rb +3 -3
  126. data/lib/braintree/validation_error.rb +1 -1
  127. data/lib/braintree/validation_error_collection.rb +3 -3
  128. data/lib/braintree/venmo_account.rb +3 -3
  129. data/lib/braintree/venmo_profile_data.rb +6 -4
  130. data/lib/braintree/version.rb +1 -1
  131. data/lib/braintree/visa_checkout_card.rb +7 -7
  132. data/lib/braintree/webhook_notification.rb +3 -2
  133. data/lib/braintree/webhook_notification_gateway.rb +4 -4
  134. data/lib/braintree/webhook_testing.rb +1 -1
  135. data/lib/braintree/webhook_testing_gateway.rb +18 -1
  136. data/lib/braintree/xml/generator.rb +1 -1
  137. data/lib/braintree/xml/libxml.rb +1 -1
  138. data/lib/braintree/xml/parser.rb +3 -3
  139. data/lib/braintree/xml/rexml.rb +2 -2
  140. data/lib/braintree/xml.rb +1 -1
  141. data/lib/braintree.rb +5 -1
  142. data/spec/integration/braintree/add_on_spec.rb +9 -9
  143. data/spec/integration/braintree/address_spec.rb +69 -69
  144. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  145. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  146. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  147. data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
  148. data/spec/integration/braintree/credit_card_spec.rb +227 -228
  149. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  150. data/spec/integration/braintree/credit_card_verification_spec.rb +98 -53
  151. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  152. data/spec/integration/braintree/customer_spec.rb +317 -317
  153. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  154. data/spec/integration/braintree/discount_spec.rb +9 -9
  155. data/spec/integration/braintree/dispute_search_spec.rb +0 -1
  156. data/spec/integration/braintree/dispute_spec.rb +87 -87
  157. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  158. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  159. data/spec/integration/braintree/http_spec.rb +28 -28
  160. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  161. data/spec/integration/braintree/merchant_spec.rb +103 -103
  162. data/spec/integration/braintree/oauth_spec.rb +61 -61
  163. data/spec/integration/braintree/package_tracking_spec.rb +111 -0
  164. data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
  165. data/spec/integration/braintree/payment_method_spec.rb +391 -391
  166. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
  167. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  168. data/spec/integration/braintree/plan_spec.rb +15 -15
  169. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  170. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  171. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  172. data/spec/integration/braintree/subscription_spec.rb +364 -364
  173. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  174. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  175. data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
  176. data/spec/integration/braintree/transaction_search_spec.rb +225 -165
  177. data/spec/integration/braintree/transaction_spec.rb +1606 -1230
  178. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  179. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  180. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  181. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  182. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  183. data/spec/spec_helper.rb +9 -8
  184. data/spec/unit/braintree/address_spec.rb +8 -8
  185. data/spec/unit/braintree/base_module_spec.rb +4 -4
  186. data/spec/unit/braintree/client_token_spec.rb +2 -2
  187. data/spec/unit/braintree/configuration_spec.rb +57 -57
  188. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  189. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  190. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +33 -28
  191. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  192. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  193. data/spec/unit/braintree/customer_spec.rb +41 -40
  194. data/spec/unit/braintree/digest_spec.rb +5 -5
  195. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  196. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  197. data/spec/unit/braintree/dispute_spec.rb +56 -56
  198. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  199. data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
  200. data/spec/unit/braintree/error_result_spec.rb +5 -5
  201. data/spec/unit/braintree/errors_spec.rb +9 -9
  202. data/spec/unit/braintree/http_spec.rb +9 -9
  203. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  204. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  205. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  206. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  207. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  208. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  209. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  210. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  211. data/spec/unit/braintree/modification_spec.rb +1 -1
  212. data/spec/unit/braintree/package_tracking_spec.rb +74 -0
  213. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  214. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  215. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  216. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  217. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  218. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  219. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  220. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  221. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  222. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  223. data/spec/unit/braintree/subscription_spec.rb +8 -8
  224. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  225. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  226. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  227. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  228. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  229. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  230. data/spec/unit/braintree/transaction_gateway_spec.rb +41 -9
  231. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  232. data/spec/unit/braintree/transaction_spec.rb +101 -93
  233. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  234. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  235. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  236. data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
  237. data/spec/unit/braintree/util_spec.rb +27 -27
  238. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  239. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  240. data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
  241. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  242. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  243. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  244. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  245. data/spec/unit/braintree/xml_spec.rb +17 -17
  246. data/spec/unit/braintree_spec.rb +2 -2
  247. metadata +14 -2
@@ -1,6 +1,6 @@
1
1
  module Braintree
2
2
  class VisaCheckoutCard
3
- include BaseModule # :nodoc:
3
+ include BaseModule
4
4
  include Braintree::Util::TokenEquality
5
5
 
6
6
  attr_reader :billing_address
@@ -30,7 +30,7 @@ module Braintree
30
30
  attr_reader :updated_at
31
31
  attr_reader :verification
32
32
 
33
- def initialize(gateway, attributes) # :nodoc:
33
+ def initialize(gateway, attributes)
34
34
  @gateway = gateway
35
35
  set_instance_variables_from_hash(attributes)
36
36
  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
@@ -39,8 +39,8 @@ module Braintree
39
39
  end
40
40
 
41
41
  def _most_recent_verification(attributes)
42
- verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
43
- CreditCardVerification._new(verification) if verification
42
+ sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
43
+ CreditCardVerification._new(sorted_verifications) if sorted_verifications
44
44
  end
45
45
 
46
46
  def default?
@@ -56,7 +56,7 @@ module Braintree
56
56
  @expired
57
57
  end
58
58
 
59
- def inspect # :nodoc:
59
+ def inspect
60
60
  first = [:token]
61
61
  order = first + (self.class._attributes - first)
62
62
  nice_attributes = order.map do |attr|
@@ -73,7 +73,7 @@ module Braintree
73
73
  protected :new
74
74
  end
75
75
 
76
- def self._attributes # :nodoc:
76
+ def self._attributes
77
77
  [
78
78
  :billing_address, :bin, :card_type, :cardholder_name, :created_at,
79
79
  :customer_id, :customer_location, :expiration_month, :expiration_year,
@@ -83,7 +83,7 @@ module Braintree
83
83
  ]
84
84
  end
85
85
 
86
- def self._new(*args) # :nodoc:
86
+ def self._new(*args)
87
87
  self.new(*args)
88
88
  end
89
89
  end
@@ -45,6 +45,7 @@ module Braintree
45
45
 
46
46
  RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
47
47
 
48
+ SubscriptionBillingSkipped = "subscription_billing_skipped"
48
49
  SubscriptionCanceled = "subscription_canceled"
49
50
  SubscriptionChargedSuccessfully = "subscription_charged_successfully"
50
51
  SubscriptionChargedUnsuccessfully = "subscription_charged_unsuccessfully"
@@ -91,7 +92,7 @@ module Braintree
91
92
  Configuration.gateway.webhook_notification.verify(*args)
92
93
  end
93
94
 
94
- def initialize(gateway, attributes) # :nodoc:
95
+ def initialize(gateway, attributes)
95
96
  @gateway = gateway
96
97
  set_instance_variables_from_hash(attributes)
97
98
  @error_result = ErrorResult.new(gateway, @subject[:api_error_response]) if @subject.has_key?(:api_error_response)
@@ -134,7 +135,7 @@ module Braintree
134
135
 
135
136
  class << self
136
137
  protected :new
137
- def _new(*args) # :nodoc:
138
+ def _new(*args)
138
139
  self.new(*args)
139
140
  end
140
141
  end
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- class WebhookNotificationGateway # :nodoc:
2
+ class WebhookNotificationGateway
3
3
  def initialize(gateway)
4
4
  @gateway = gateway
5
5
  @config = gateway.config
@@ -27,7 +27,7 @@ module Braintree
27
27
  signature_pairs = signature_string.split("&")
28
28
  valid_pairs = signature_pairs.select { |pair| pair.include?("|") }.map { |pair| pair.split("|") }
29
29
 
30
- valid_pairs.detect do |public_key, signature|
30
+ valid_pairs.detect do |public_key, _signature|
31
31
  public_key == @config.public_key
32
32
  end
33
33
  end
@@ -36,8 +36,8 @@ module Braintree
36
36
  public_key, signature = _matching_signature_pair(signature_string)
37
37
  raise InvalidSignature, "no matching public key" if public_key.nil?
38
38
 
39
- signature_matches = [payload, payload + "\n"].any? do |payload|
40
- payload_signature = Braintree::Digest.hexdigest(@config.private_key, payload)
39
+ signature_matches = [payload, payload + "\n"].any? do |p|
40
+ payload_signature = Braintree::Digest.hexdigest(@config.private_key, p)
41
41
  Braintree::Digest.secure_compare(signature, payload_signature)
42
42
  end
43
43
  raise InvalidSignature, "signature does not match payload - one has been modified" unless signature_matches
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- class WebhookTesting # :nodoc:
2
+ class WebhookTesting
3
3
  def self.sample_notification(*args)
4
4
  Configuration.gateway.webhook_testing.sample_notification(*args)
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- class WebhookTestingGateway # :nodoc:
2
+ class WebhookTestingGateway
3
3
  def initialize(gateway)
4
4
  @gateway = gateway
5
5
  @config = gateway.config
@@ -72,6 +72,8 @@ module Braintree
72
72
  _disbursement_exception_sample_xml(id)
73
73
  when Braintree::WebhookNotification::Kind::Disbursement
74
74
  _disbursement_sample_xml(id)
75
+ when Braintree::WebhookNotification::Kind::SubscriptionBillingSkipped
76
+ _subscription_billing_skipped(id)
75
77
  when Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully
76
78
  _subscription_charged_successfully(id)
77
79
  when Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully
@@ -112,6 +114,21 @@ module Braintree
112
114
  XML
113
115
  end
114
116
 
117
+ def _subscription_billing_skipped(id)
118
+
119
+ <<-XML
120
+ <subscription>
121
+ <id>#{id}</id>
122
+ <transactions type="array">
123
+ </transactions>
124
+ <add_ons type="array">
125
+ </add_ons>
126
+ <discounts type="array">
127
+ </discounts>
128
+ </subscription>
129
+ XML
130
+ end
131
+
115
132
  def _subscription_charged_successfully(id)
116
133
 
117
134
  <<-XML
@@ -2,7 +2,7 @@
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
4
  module Xml
5
- module Generator # :nodoc:
5
+ module Generator
6
6
  XML_TYPE_NAMES = {
7
7
  "Fixnum" => "integer",
8
8
  "Bignum" => "integer",
@@ -2,7 +2,7 @@
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
4
  module Xml
5
- module Libxml # :nodoc:
5
+ module Libxml
6
6
  LIB_XML_LIMIT = 30000000
7
7
 
8
8
  def self.parse(xml_string)
@@ -1,10 +1,10 @@
1
1
  # Portions of this code were copied and modified from Ruby on Rails, released
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
- module Xml # :nodoc:
4
+ module Xml
5
5
  CONTENT_ROOT = "__content__"
6
6
 
7
- module Parser # :nodoc:
7
+ module Parser
8
8
  XML_PARSING = {
9
9
  "datetime" => Proc.new { |time| ::Time.parse(time).utc },
10
10
  "integer" => Proc.new { |integer| integer.to_i },
@@ -32,7 +32,7 @@ module Braintree
32
32
  case value.class.to_s
33
33
  when "Hash"
34
34
  if value["type"] == "array"
35
- child_key, entries = value.detect { |k,v| k != "type" } # child_key is throwaway
35
+ child_key, entries = value.detect { |k,_v| k != "type" } # child_key is throwaway
36
36
  if entries.nil? || ((c = value[CONTENT_ROOT]) && c.strip.empty?)
37
37
  []
38
38
  else
@@ -1,8 +1,8 @@
1
1
  # Portions of this code were copied and modified from Ruby on Rails, released
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
- module Xml # :nodoc:
5
- module Rexml # :nodoc:
4
+ module Xml
5
+ module Rexml
6
6
 
7
7
  CONTENT_KEY = "__content__".freeze
8
8
 
data/lib/braintree/xml.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- module Xml # :nodoc:
2
+ module Xml
3
3
  def self.hash_from_xml(xml)
4
4
  Parser.hash_from_xml(xml)
5
5
  end
data/lib/braintree.rb CHANGED
@@ -3,7 +3,6 @@ require "bigdecimal"
3
3
  require "cgi"
4
4
  require "date"
5
5
  require "digest/sha1"
6
- require "enumerator"
7
6
  require "forwardable"
8
7
  require "logger"
9
8
  require "net/http"
@@ -91,6 +90,8 @@ require "braintree/merchant_account/individual_details"
91
90
  require "braintree/merchant_account/business_details"
92
91
  require "braintree/merchant_account/funding_details"
93
92
  require "braintree/merchant_account/address_details"
93
+ require "braintree/meta_checkout_card"
94
+ require "braintree/meta_checkout_token"
94
95
  require "braintree/oauth_gateway"
95
96
  require "braintree/oauth_credentials"
96
97
  require "braintree/payment_instrument_type"
@@ -153,6 +154,9 @@ require "braintree/transaction/installment/adjustment"
153
154
  require "braintree/transaction/payment_receipt"
154
155
  require "braintree/transaction/payment_receipt/card_present_data.rb"
155
156
  require "braintree/transaction/payment_receipt/merchant_address.rb"
157
+ require "braintree/transaction/meta_checkout_card_details"
158
+ require "braintree/transaction/meta_checkout_token_details"
159
+ require "braintree/transaction/package_details"
156
160
  require "braintree/transaction/paypal_details"
157
161
  require "braintree/transaction/paypal_here_details"
158
162
  require "braintree/transaction/samsung_pay_card_details"
@@ -20,15 +20,15 @@ describe Braintree::AddOn do
20
20
  add_ons = Braintree::AddOn.all
21
21
  add_on = add_ons.select { |add_on| add_on.id == id }.first
22
22
 
23
- add_on.should_not be_nil
24
- add_on.amount.should == BigDecimal(expected[:amount])
25
- add_on.created_at.should_not be_nil
26
- add_on.description.should == expected[:description]
27
- add_on.kind.should == expected[:kind]
28
- add_on.name.should == expected[:name]
29
- add_on.never_expires.should == expected[:never_expires]
30
- add_on.number_of_billing_cycles.should == expected[:number_of_billing_cycles]
31
- add_on.updated_at.should_not be_nil
23
+ expect(add_on).not_to be_nil
24
+ expect(add_on.amount).to eq(BigDecimal(expected[:amount]))
25
+ expect(add_on.created_at).not_to be_nil
26
+ expect(add_on.description).to eq(expected[:description])
27
+ expect(add_on.kind).to eq(expected[:kind])
28
+ expect(add_on.name).to eq(expected[:name])
29
+ expect(add_on.never_expires).to eq(expected[:never_expires])
30
+ expect(add_on.number_of_billing_cycles).to eq(expected[:number_of_billing_cycles])
31
+ expect(add_on.updated_at).not_to be_nil
32
32
  end
33
33
 
34
34
  it "raises with a helpful error if public_key and private_key are not set" do
@@ -18,21 +18,21 @@ describe Braintree::Address do
18
18
  :postal_code => "60622",
19
19
  :country_name => "United States of America",
20
20
  )
21
- result.success?.should == true
22
- result.address.customer_id.should == customer.id
23
- result.address.first_name.should == "Ben"
24
- result.address.last_name.should == "Moore"
25
- result.address.company.should == "Moore Co."
26
- result.address.street_address.should == "1811 E Main St"
27
- result.address.extended_address.should == "Suite 200"
28
- result.address.locality.should == "Chicago"
29
- result.address.region.should == "Illinois"
30
- result.address.phone_number.should == "5551231234"
31
- result.address.postal_code.should == "60622"
32
- result.address.country_name.should == "United States of America"
33
- result.address.country_code_alpha2.should == "US"
34
- result.address.country_code_alpha3.should == "USA"
35
- result.address.country_code_numeric.should == "840"
21
+ expect(result.success?).to eq(true)
22
+ expect(result.address.customer_id).to eq(customer.id)
23
+ expect(result.address.first_name).to eq("Ben")
24
+ expect(result.address.last_name).to eq("Moore")
25
+ expect(result.address.company).to eq("Moore Co.")
26
+ expect(result.address.street_address).to eq("1811 E Main St")
27
+ expect(result.address.extended_address).to eq("Suite 200")
28
+ expect(result.address.locality).to eq("Chicago")
29
+ expect(result.address.region).to eq("Illinois")
30
+ expect(result.address.phone_number).to eq("5551231234")
31
+ expect(result.address.postal_code).to eq("60622")
32
+ expect(result.address.country_name).to eq("United States of America")
33
+ expect(result.address.country_code_alpha2).to eq("US")
34
+ expect(result.address.country_code_alpha3).to eq("USA")
35
+ expect(result.address.country_code_numeric).to eq("840")
36
36
  end
37
37
 
38
38
  it "accepts country_codes" do
@@ -43,11 +43,11 @@ describe Braintree::Address do
43
43
  :country_code_alpha3 => "ASM",
44
44
  :country_code_numeric => "16",
45
45
  )
46
- result.success?.should == true
47
- result.address.country_name.should == "American Samoa"
48
- result.address.country_code_alpha2.should == "AS"
49
- result.address.country_code_alpha3.should == "ASM"
50
- result.address.country_code_numeric.should == "016"
46
+ expect(result.success?).to eq(true)
47
+ expect(result.address.country_name).to eq("American Samoa")
48
+ expect(result.address.country_code_alpha2).to eq("AS")
49
+ expect(result.address.country_code_alpha3).to eq("ASM")
50
+ expect(result.address.country_code_numeric).to eq("016")
51
51
  end
52
52
 
53
53
  it "accepts utf-8 country names" do
@@ -56,8 +56,8 @@ describe Braintree::Address do
56
56
  :customer_id => customer.id,
57
57
  :country_name => "Åland",
58
58
  )
59
- result.success?.should == true
60
- result.address.country_name.should == "Åland"
59
+ expect(result.success?).to eq(true)
60
+ expect(result.address.country_name).to eq("Åland")
61
61
  end
62
62
 
63
63
  it "returns an error response given inconsistent country codes" do
@@ -67,8 +67,8 @@ describe Braintree::Address do
67
67
  :country_code_alpha2 => "AS",
68
68
  :country_code_alpha3 => "USA",
69
69
  )
70
- result.success?.should == false
71
- result.errors.for(:address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
70
+ expect(result.success?).to eq(false)
71
+ expect(result.errors.for(:address).on(:base).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::InconsistentCountry)
72
72
  end
73
73
 
74
74
  it "returns an error response given an invalid country_code_alpha2" do
@@ -77,8 +77,8 @@ describe Braintree::Address do
77
77
  :customer_id => customer.id,
78
78
  :country_code_alpha2 => "zz",
79
79
  )
80
- result.success?.should == false
81
- result.errors.for(:address).on(:country_code_alpha2).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
80
+ expect(result.success?).to eq(false)
81
+ expect(result.errors.for(:address).on(:country_code_alpha2).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
82
82
  end
83
83
 
84
84
  it "returns an error response given an invalid country_code_alpha3" do
@@ -87,8 +87,8 @@ describe Braintree::Address do
87
87
  :customer_id => customer.id,
88
88
  :country_code_alpha3 => "zzz",
89
89
  )
90
- result.success?.should == false
91
- result.errors.for(:address).on(:country_code_alpha3).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
90
+ expect(result.success?).to eq(false)
91
+ expect(result.errors.for(:address).on(:country_code_alpha3).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
92
92
  end
93
93
 
94
94
  it "returns an error response given an invalid country_code_numeric" do
@@ -97,8 +97,8 @@ describe Braintree::Address do
97
97
  :customer_id => customer.id,
98
98
  :country_code_numeric => "zz",
99
99
  )
100
- result.success?.should == false
101
- result.errors.for(:address).on(:country_code_numeric).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
100
+ expect(result.success?).to eq(false)
101
+ expect(result.errors.for(:address).on(:country_code_numeric).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
102
102
  end
103
103
 
104
104
  it "returns an error response if invalid" do
@@ -107,8 +107,8 @@ describe Braintree::Address do
107
107
  :customer_id => customer.id,
108
108
  :country_name => "United States of Invalid",
109
109
  )
110
- result.success?.should == false
111
- result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
110
+ expect(result.success?).to eq(false)
111
+ expect(result.errors.for(:address).on(:country_name)[0].message).to eq("Country name is not an accepted country.")
112
112
  end
113
113
 
114
114
  it "allows -, _, A-Z, a-z, and 0-9 in customer_id without raising an ArgumentError" do
@@ -137,14 +137,14 @@ describe Braintree::Address do
137
137
  :postal_code => "60623",
138
138
  :country_name => "United States of America",
139
139
  )
140
- address.customer_id.should == customer.id
141
- address.street_address.should == "1812 E Main St"
142
- address.extended_address.should == "Suite 201"
143
- address.locality.should == "Bartlett"
144
- address.region.should == "IL"
145
- address.phone_number.should == "5551231234"
146
- address.postal_code.should == "60623"
147
- address.country_name.should == "United States of America"
140
+ expect(address.customer_id).to eq(customer.id)
141
+ expect(address.street_address).to eq("1812 E Main St")
142
+ expect(address.extended_address).to eq("Suite 201")
143
+ expect(address.locality).to eq("Bartlett")
144
+ expect(address.region).to eq("IL")
145
+ expect(address.phone_number).to eq("5551231234")
146
+ expect(address.postal_code).to eq("60623")
147
+ expect(address.country_name).to eq("United States of America")
148
148
  end
149
149
 
150
150
  it "raises a ValidationsFailed if invalid" do
@@ -162,7 +162,7 @@ describe Braintree::Address do
162
162
  it "deletes the address given a customer id and an address id" do
163
163
  customer = Braintree::Customer.create!(:last_name => "Wilson")
164
164
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
165
- Braintree::Address.delete(customer.id, address.id).success?.should == true
165
+ expect(Braintree::Address.delete(customer.id, address.id).success?).to eq(true)
166
166
  expect do
167
167
  Braintree::Address.find(customer.id, address.id)
168
168
  end.to raise_error(Braintree::NotFoundError)
@@ -171,7 +171,7 @@ describe Braintree::Address do
171
171
  it "deletes the address given a customer and an address id" do
172
172
  customer = Braintree::Customer.create!(:last_name => "Wilson")
173
173
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
174
- Braintree::Address.delete(customer, address.id).success?.should == true
174
+ expect(Braintree::Address.delete(customer, address.id).success?).to eq(true)
175
175
  expect do
176
176
  Braintree::Address.find(customer.id, address.id)
177
177
  end.to raise_error(Braintree::NotFoundError)
@@ -182,13 +182,13 @@ describe Braintree::Address do
182
182
  it "finds the address given a customer and an address id" do
183
183
  customer = Braintree::Customer.create!(:last_name => "Wilson")
184
184
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
185
- Braintree::Address.find(customer, address.id).should == address
185
+ expect(Braintree::Address.find(customer, address.id)).to eq(address)
186
186
  end
187
187
 
188
188
  it "finds the address given a customer id and an address id" do
189
189
  customer = Braintree::Customer.create!(:last_name => "Wilson")
190
190
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
191
- Braintree::Address.find(customer.id, address.id).should == address
191
+ expect(Braintree::Address.find(customer.id, address.id)).to eq(address)
192
192
  end
193
193
 
194
194
  it "raises a NotFoundError if it cannot be found because of customer id" do
@@ -242,16 +242,16 @@ describe Braintree::Address do
242
242
  :postal_code => "60621",
243
243
  :country_name => "United States of America",
244
244
  )
245
- result.success?.should == true
246
- result.address.street_address.should == "123 E New St"
247
- result.address.extended_address.should == "New Suite 3"
248
- result.address.locality.should == "Chicago"
249
- result.address.region.should == "Illinois"
250
- result.address.postal_code.should == "60621"
251
- result.address.country_name.should == "United States of America"
252
- result.address.country_code_alpha2.should == "US"
253
- result.address.country_code_alpha3.should == "USA"
254
- result.address.country_code_numeric.should == "840"
245
+ expect(result.success?).to eq(true)
246
+ expect(result.address.street_address).to eq("123 E New St")
247
+ expect(result.address.extended_address).to eq("New Suite 3")
248
+ expect(result.address.locality).to eq("Chicago")
249
+ expect(result.address.region).to eq("Illinois")
250
+ expect(result.address.postal_code).to eq("60621")
251
+ expect(result.address.country_name).to eq("United States of America")
252
+ expect(result.address.country_code_alpha2).to eq("US")
253
+ expect(result.address.country_code_alpha3).to eq("USA")
254
+ expect(result.address.country_code_numeric).to eq("840")
255
255
  end
256
256
 
257
257
  it "accepts country_codes" do
@@ -266,11 +266,11 @@ describe Braintree::Address do
266
266
  :country_name => "Azerbaijan",
267
267
  )
268
268
 
269
- result.success?.should == true
270
- result.address.country_name.should == "Azerbaijan"
271
- result.address.country_code_alpha2.should == "AZ"
272
- result.address.country_code_alpha3.should == "AZE"
273
- result.address.country_code_numeric.should == "031"
269
+ expect(result.success?).to eq(true)
270
+ expect(result.address.country_name).to eq("Azerbaijan")
271
+ expect(result.address.country_code_alpha2).to eq("AZ")
272
+ expect(result.address.country_code_alpha3).to eq("AZE")
273
+ expect(result.address.country_code_numeric).to eq("031")
274
274
  end
275
275
 
276
276
  it "returns an error response if invalid" do
@@ -285,8 +285,8 @@ describe Braintree::Address do
285
285
  :street_address => "123 E New St",
286
286
  :country_name => "United States of Invalid",
287
287
  )
288
- result.success?.should == false
289
- result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
288
+ expect(result.success?).to eq(false)
289
+ expect(result.errors.for(:address).on(:country_name)[0].message).to eq("Country name is not an accepted country.")
290
290
  end
291
291
  end
292
292
 
@@ -320,13 +320,13 @@ describe Braintree::Address do
320
320
  :postal_code => "60621",
321
321
  :country_name => "United States of America",
322
322
  )
323
- updated_address.should == address
324
- updated_address.street_address.should == "123 E New St"
325
- updated_address.extended_address.should == "New Suite 3"
326
- updated_address.locality.should == "Chicago"
327
- updated_address.region.should == "Illinois"
328
- updated_address.postal_code.should == "60621"
329
- updated_address.country_name.should == "United States of America"
323
+ expect(updated_address).to eq(address)
324
+ expect(updated_address.street_address).to eq("123 E New St")
325
+ expect(updated_address.extended_address).to eq("New Suite 3")
326
+ expect(updated_address.locality).to eq("Chicago")
327
+ expect(updated_address.region).to eq("Illinois")
328
+ expect(updated_address.postal_code).to eq("60621")
329
+ expect(updated_address.country_name).to eq("United States of America")
330
330
  end
331
331
 
332
332
  it "raises a ValidationsFailed invalid" do
@@ -352,7 +352,7 @@ describe Braintree::Address do
352
352
  customer = Braintree::Customer.create!(:last_name => "Wilson")
353
353
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
354
354
  result = Braintree::Address.delete(customer.id, address.id)
355
- result.success?.should == true
355
+ expect(result.success?).to eq(true)
356
356
  expect do
357
357
  Braintree::Address.find(customer.id, address.id)
358
358
  end.to raise_error(Braintree::NotFoundError)