braintree 4.14.0 → 4.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) 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_search.rb +1 -1
  22. data/lib/braintree/customer.rb +5 -9
  23. data/lib/braintree/customer_gateway.rb +7 -7
  24. data/lib/braintree/customer_search.rb +1 -1
  25. data/lib/braintree/descriptor.rb +1 -1
  26. data/lib/braintree/digest.rb +1 -1
  27. data/lib/braintree/disbursement.rb +5 -5
  28. data/lib/braintree/discount_gateway.rb +1 -1
  29. data/lib/braintree/dispute/evidence.rb +1 -1
  30. data/lib/braintree/dispute/paypal_message.rb +1 -1
  31. data/lib/braintree/dispute/status_history.rb +1 -1
  32. data/lib/braintree/dispute/transaction.rb +1 -1
  33. data/lib/braintree/dispute/transaction_details.rb +1 -1
  34. data/lib/braintree/dispute.rb +3 -3
  35. data/lib/braintree/dispute_gateway.rb +1 -1
  36. data/lib/braintree/dispute_search.rb +1 -1
  37. data/lib/braintree/document_upload.rb +2 -2
  38. data/lib/braintree/document_upload_gateway.rb +3 -3
  39. data/lib/braintree/enriched_customer_data.rb +2 -2
  40. data/lib/braintree/error_result.rb +2 -3
  41. data/lib/braintree/errors.rb +3 -3
  42. data/lib/braintree/exceptions.rb +1 -2
  43. data/lib/braintree/exchange_rate.rb +2 -2
  44. data/lib/braintree/exchange_rate_quote.rb +3 -3
  45. data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
  46. data/lib/braintree/exchange_rate_quote_input.rb +3 -3
  47. data/lib/braintree/exchange_rate_quote_request.rb +3 -3
  48. data/lib/braintree/exchange_rate_quote_response.rb +3 -3
  49. data/lib/braintree/facilitated_details.rb +1 -1
  50. data/lib/braintree/facilitator_details.rb +1 -1
  51. data/lib/braintree/google_pay_card.rb +3 -3
  52. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  53. data/lib/braintree/graphql_client.rb +1 -1
  54. data/lib/braintree/http.rb +1 -1
  55. data/lib/braintree/local_payment_completed.rb +2 -2
  56. data/lib/braintree/local_payment_expired.rb +2 -2
  57. data/lib/braintree/local_payment_funded.rb +2 -2
  58. data/lib/braintree/local_payment_reversed.rb +2 -2
  59. data/lib/braintree/merchant.rb +3 -3
  60. data/lib/braintree/merchant_account.rb +2 -2
  61. data/lib/braintree/merchant_account_gateway.rb +9 -9
  62. data/lib/braintree/meta_checkout_card.rb +89 -0
  63. data/lib/braintree/meta_checkout_token.rb +88 -0
  64. data/lib/braintree/modification.rb +3 -3
  65. data/lib/braintree/oauth_credentials.rb +3 -3
  66. data/lib/braintree/paginated_collection.rb +2 -2
  67. data/lib/braintree/paginated_result.rb +1 -1
  68. data/lib/braintree/payment_instrument_type.rb +2 -0
  69. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
  70. data/lib/braintree/payment_method_gateway.rb +23 -10
  71. data/lib/braintree/payment_method_nonce.rb +4 -4
  72. data/lib/braintree/payment_method_nonce_details.rb +1 -1
  73. data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
  74. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  75. data/lib/braintree/paypal_account.rb +1 -2
  76. data/lib/braintree/paypal_account_gateway.rb +5 -5
  77. data/lib/braintree/plan.rb +1 -1
  78. data/lib/braintree/plan_gateway.rb +2 -2
  79. data/lib/braintree/resource_collection.rb +2 -2
  80. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  81. data/lib/braintree/risk_data.rb +1 -1
  82. data/lib/braintree/samsung_pay_card.rb +5 -5
  83. data/lib/braintree/sepa_direct_debit_account.rb +2 -2
  84. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
  85. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  86. data/lib/braintree/sha256_digest.rb +1 -1
  87. data/lib/braintree/subscription/status_details.rb +1 -1
  88. data/lib/braintree/subscription.rb +2 -2
  89. data/lib/braintree/subscription_gateway.rb +6 -6
  90. data/lib/braintree/subscription_search.rb +1 -1
  91. data/lib/braintree/successful_result.rb +2 -2
  92. data/lib/braintree/test/credit_card.rb +7 -10
  93. data/lib/braintree/test/merchant_account.rb +1 -1
  94. data/lib/braintree/test/nonce.rb +4 -0
  95. data/lib/braintree/test/transaction_amounts.rb +2 -3
  96. data/lib/braintree/test/venmo_sdk.rb +2 -0
  97. data/lib/braintree/testing_gateway.rb +1 -1
  98. data/lib/braintree/three_d_secure_info.rb +1 -1
  99. data/lib/braintree/transaction/address_details.rb +1 -1
  100. data/lib/braintree/transaction/credit_card_details.rb +4 -1
  101. data/lib/braintree/transaction/customer_details.rb +1 -1
  102. data/lib/braintree/transaction/disbursement_details.rb +1 -1
  103. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  104. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  105. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  106. data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
  107. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
  108. data/lib/braintree/transaction/status_details.rb +1 -1
  109. data/lib/braintree/transaction/subscription_details.rb +1 -1
  110. data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
  111. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  112. data/lib/braintree/transaction.rb +27 -20
  113. data/lib/braintree/transaction_gateway.rb +23 -12
  114. data/lib/braintree/transaction_line_item.rb +2 -2
  115. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  116. data/lib/braintree/transaction_review.rb +1 -1
  117. data/lib/braintree/transaction_search.rb +7 -6
  118. data/lib/braintree/unknown_payment_method.rb +1 -1
  119. data/lib/braintree/us_bank_account.rb +2 -2
  120. data/lib/braintree/us_bank_account_verification.rb +23 -15
  121. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  122. data/lib/braintree/util.rb +3 -3
  123. data/lib/braintree/validation_error.rb +1 -1
  124. data/lib/braintree/validation_error_collection.rb +3 -3
  125. data/lib/braintree/venmo_account.rb +3 -3
  126. data/lib/braintree/venmo_profile_data.rb +6 -4
  127. data/lib/braintree/version.rb +1 -1
  128. data/lib/braintree/visa_checkout_card.rb +7 -7
  129. data/lib/braintree/webhook_notification.rb +3 -2
  130. data/lib/braintree/webhook_notification_gateway.rb +3 -3
  131. data/lib/braintree/webhook_testing.rb +1 -1
  132. data/lib/braintree/webhook_testing_gateway.rb +18 -1
  133. data/lib/braintree/xml/generator.rb +1 -1
  134. data/lib/braintree/xml/libxml.rb +1 -1
  135. data/lib/braintree/xml/parser.rb +2 -2
  136. data/lib/braintree/xml/rexml.rb +2 -2
  137. data/lib/braintree/xml.rb +1 -1
  138. data/lib/braintree.rb +4 -1
  139. data/spec/integration/braintree/add_on_spec.rb +9 -9
  140. data/spec/integration/braintree/address_spec.rb +69 -69
  141. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  142. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  143. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  144. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  145. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  146. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  147. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  148. data/spec/integration/braintree/customer_spec.rb +313 -313
  149. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  150. data/spec/integration/braintree/discount_spec.rb +9 -9
  151. data/spec/integration/braintree/dispute_search_spec.rb +0 -1
  152. data/spec/integration/braintree/dispute_spec.rb +87 -87
  153. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  154. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  155. data/spec/integration/braintree/http_spec.rb +28 -28
  156. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  157. data/spec/integration/braintree/merchant_spec.rb +103 -103
  158. data/spec/integration/braintree/oauth_spec.rb +61 -61
  159. data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
  160. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  161. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
  162. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  163. data/spec/integration/braintree/plan_spec.rb +15 -15
  164. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  165. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  166. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  167. data/spec/integration/braintree/subscription_spec.rb +364 -364
  168. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  169. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  170. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  171. data/spec/integration/braintree/transaction_search_spec.rb +225 -165
  172. data/spec/integration/braintree/transaction_spec.rb +1502 -1210
  173. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  174. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  175. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  176. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  177. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  178. data/spec/spec_helper.rb +9 -8
  179. data/spec/unit/braintree/address_spec.rb +8 -8
  180. data/spec/unit/braintree/base_module_spec.rb +4 -4
  181. data/spec/unit/braintree/client_token_spec.rb +2 -2
  182. data/spec/unit/braintree/configuration_spec.rb +57 -57
  183. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  184. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  185. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  186. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  187. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  188. data/spec/unit/braintree/customer_spec.rb +41 -40
  189. data/spec/unit/braintree/digest_spec.rb +5 -5
  190. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  191. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  192. data/spec/unit/braintree/dispute_spec.rb +56 -56
  193. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  194. data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
  195. data/spec/unit/braintree/error_result_spec.rb +5 -5
  196. data/spec/unit/braintree/errors_spec.rb +9 -9
  197. data/spec/unit/braintree/http_spec.rb +9 -9
  198. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  199. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  200. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  201. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  202. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  203. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  204. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  205. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  206. data/spec/unit/braintree/modification_spec.rb +1 -1
  207. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  208. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  209. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  210. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  211. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  212. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  213. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  214. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  215. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  216. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  217. data/spec/unit/braintree/subscription_spec.rb +8 -8
  218. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  219. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  220. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  221. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  222. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  223. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  224. data/spec/unit/braintree/transaction_gateway_spec.rb +39 -7
  225. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  226. data/spec/unit/braintree/transaction_spec.rb +101 -93
  227. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  228. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  229. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  230. data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
  231. data/spec/unit/braintree/util_spec.rb +27 -27
  232. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  233. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  234. data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
  235. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  236. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  237. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  238. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  239. data/spec/unit/braintree/xml_spec.rb +17 -17
  240. data/spec/unit/braintree_spec.rb +2 -2
  241. metadata +11 -2
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::Transaction::MetaCheckoutCardDetails do
4
+ let(:attributes) do {
5
+
6
+ :bin => "abc1234",
7
+ :container_id => "a-container-id",
8
+ :card_type => "Visa",
9
+ :cardholder_name => "Meta Checkout Card CardHolder",
10
+ :commercial => "NO",
11
+ :country_of_issuance => "US",
12
+ :created_at => "2023-05-05T21:28:37Z",
13
+ :debit => "NO",
14
+ :durbin_regulated => "NO",
15
+ :expiration_month => "05",
16
+ :expiration_year => "2024",
17
+ :healthcare => "NO",
18
+ :last_4 => "1234",
19
+ :payroll => "NO",
20
+ :prepaid => "NO",
21
+ :token => "token1",
22
+ :unique_number_identifier => "abc1234",
23
+ :updated_at => "2023-05-05T21:28:37Z"
24
+ }
25
+ end
26
+
27
+ describe "unit tests" do
28
+ it "initializes with the correct attributes" do
29
+ card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
30
+
31
+ card.bin.should == "abc1234"
32
+ card.container_id.should == "a-container-id"
33
+ card.card_type.should == "Visa"
34
+ card.cardholder_name.should == "Meta Checkout Card CardHolder"
35
+ card.commercial == "NO"
36
+ card.country_of_issuance == "US"
37
+ card.created_at == "2023-05-05T21:28:37Z"
38
+ card.updated_at == "2023-05-05T21:28:37Z"
39
+ card.debit == "NO"
40
+ card.payroll == "NO"
41
+ card.prepaid == "NO"
42
+ card.healthcare == "NO"
43
+ card.token == "token1"
44
+ card.unique_number_identifier == "abc1234"
45
+ card.expiration_month.should == "05"
46
+ card.expiration_year.should == "2024"
47
+ card.last_4.should == "1234"
48
+ end
49
+
50
+ it "sets expiration date correctly" do
51
+ card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
52
+ card.expiration_date.should == "05/2024"
53
+ end
54
+
55
+ it "masks the card number correctly" do
56
+ card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
57
+ card.masked_number.should == "abc1234******1234"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::MetaCheckoutCard do
4
+ let(:attributes) do {
5
+
6
+ :bin => "abc1234",
7
+ :container_id => "a-container-id",
8
+ :card_type => "Visa",
9
+ :cardholder_name => "Meta Checkout Card CardHolder",
10
+ :commercial => "NO",
11
+ :country_of_issuance => "US",
12
+ :created_at => "2023-05-05T21:28:37Z",
13
+ :debit => "NO",
14
+ :durbin_regulated => "NO",
15
+ :expiration_month => "05",
16
+ :expiration_year => "2024",
17
+ :healthcare => "NO",
18
+ :last_4 => "1234",
19
+ :payroll => "NO",
20
+ :prepaid => "NO",
21
+ :token => "token1",
22
+ :unique_number_identifier => "abc1234",
23
+ :updated_at => "2023-05-05T21:28:37Z"
24
+ }
25
+ end
26
+
27
+ describe "unit tests" do
28
+ it "initializes with the correct attributes" do
29
+ card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
30
+
31
+ card.bin.should == "abc1234"
32
+ card.container_id.should == "a-container-id"
33
+ card.card_type.should == "Visa"
34
+ card.cardholder_name.should == "Meta Checkout Card CardHolder"
35
+ card.commercial == "NO"
36
+ card.country_of_issuance == "US"
37
+ card.created_at == "2023-05-05T21:28:37Z"
38
+ card.updated_at == "2023-05-05T21:28:37Z"
39
+ card.debit == "NO"
40
+ card.payroll == "NO"
41
+ card.prepaid == "NO"
42
+ card.healthcare == "NO"
43
+ card.token == "token1"
44
+ card.unique_number_identifier == "abc1234"
45
+ card.expiration_month.should == "05"
46
+ card.expiration_year.should == "2024"
47
+ card.last_4.should == "1234"
48
+ end
49
+
50
+ it "sets expiration date correctly" do
51
+ card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
52
+ card.expiration_date.should == "05/2024"
53
+ end
54
+
55
+ it "masks the card number correctly" do
56
+ card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
57
+ card.masked_number.should == "abc1234******1234"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::Transaction::MetaCheckoutTokenDetails do
4
+ let(:attributes) do {
5
+ :bin => "abc1234",
6
+ :container_id => "a-container-id",
7
+ :card_type => "Visa",
8
+ :cardholder_name => "Meta Checkout Card CardHolder",
9
+ :commercial => "NO",
10
+ :country_of_issuance => "US",
11
+ :created_at => "2023-05-05T21:28:37Z",
12
+ :debit => "NO",
13
+ :durbin_regulated => "NO",
14
+ :expiration_month => "05",
15
+ :expiration_year => "2024",
16
+ :healthcare => "NO",
17
+ :last_4 => "1234",
18
+ :payroll => "NO",
19
+ :prepaid => "NO",
20
+ :token => "token1",
21
+ :unique_number_identifier => "abc1234",
22
+ :updated_at => "2023-05-05T21:28:37Z",
23
+ :cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==",
24
+ :ecommerce_indicator => "07"
25
+ }
26
+ end
27
+
28
+ describe "unit tests" do
29
+ it "initializes with the correct attributes" do
30
+ card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
31
+
32
+ card.bin.should == "abc1234"
33
+ card.container_id.should == "a-container-id"
34
+ card.card_type.should == "Visa"
35
+ card.cardholder_name.should == "Meta Checkout Card CardHolder"
36
+ card.commercial == "NO"
37
+ card.country_of_issuance == "US"
38
+ card.created_at == "2023-05-05T21:28:37Z"
39
+ card.updated_at == "2023-05-05T21:28:37Z"
40
+ card.debit == "NO"
41
+ card.payroll == "NO"
42
+ card.prepaid == "NO"
43
+ card.healthcare == "NO"
44
+ card.token == "token1"
45
+ card.unique_number_identifier == "abc1234"
46
+ card.expiration_month.should == "05"
47
+ card.expiration_year.should == "2024"
48
+ card.last_4.should == "1234"
49
+ card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
50
+ card.ecommerce_indicator == "07"
51
+ end
52
+
53
+ it "sets expiration date correctly" do
54
+ card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
55
+ card.expiration_date.should == "05/2024"
56
+ end
57
+
58
+ it "masks the card number correctly" do
59
+ card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
60
+ card.masked_number.should == "abc1234******1234"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::MetaCheckoutToken do
4
+ let(:attributes) do {
5
+ :bin => "abc1234",
6
+ :container_id => "a-container-id",
7
+ :card_type => "Visa",
8
+ :cardholder_name => "Meta Checkout Card CardHolder",
9
+ :commercial => "NO",
10
+ :country_of_issuance => "US",
11
+ :created_at => "2023-05-05T21:28:37Z",
12
+ :debit => "NO",
13
+ :durbin_regulated => "NO",
14
+ :expiration_month => "05",
15
+ :expiration_year => "2024",
16
+ :healthcare => "NO",
17
+ :last_4 => "1234",
18
+ :payroll => "NO",
19
+ :prepaid => "NO",
20
+ :token => "token1",
21
+ :unique_number_identifier => "abc1234",
22
+ :updated_at => "2023-05-05T21:28:37Z",
23
+ :cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==",
24
+ :ecommerce_indicator => "07"
25
+ }
26
+ end
27
+
28
+ describe "unit tests" do
29
+ it "initializes with the correct attributes" do
30
+ card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
31
+
32
+ card.bin.should == "abc1234"
33
+ card.container_id.should == "a-container-id"
34
+ card.card_type.should == "Visa"
35
+ card.cardholder_name.should == "Meta Checkout Card CardHolder"
36
+ card.commercial == "NO"
37
+ card.country_of_issuance == "US"
38
+ card.created_at == "2023-05-05T21:28:37Z"
39
+ card.updated_at == "2023-05-05T21:28:37Z"
40
+ card.debit == "NO"
41
+ card.payroll == "NO"
42
+ card.prepaid == "NO"
43
+ card.healthcare == "NO"
44
+ card.token == "token1"
45
+ card.unique_number_identifier == "abc1234"
46
+ card.expiration_month.should == "05"
47
+ card.expiration_year.should == "2024"
48
+ card.last_4.should == "1234"
49
+ card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
50
+ card.ecommerce_indicator == "07"
51
+ end
52
+
53
+ it "sets expiration date correctly" do
54
+ card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
55
+ card.expiration_date.should == "05/2024"
56
+ end
57
+
58
+ it "masks the card number correctly" do
59
+ card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
60
+ card.masked_number.should == "abc1234******1234"
61
+ end
62
+ end
63
+ end
@@ -2,6 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Braintree::Modification do
4
4
  it "converts string amount" do
5
- Braintree::Modification._new(:amount => "100.00").amount.should == BigDecimal("100.00")
5
+ expect(Braintree::Modification._new(:amount => "100.00").amount).to eq(BigDecimal("100.00"))
6
6
  end
7
7
  end
@@ -34,12 +34,12 @@ describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
34
34
 
35
35
  payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
36
36
 
37
- payment_method_customer_data_updated.token.should eq("a-token")
38
- payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
39
- payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
40
- payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
41
- payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
42
- payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
37
+ expect(payment_method_customer_data_updated.token).to eq("a-token")
38
+ expect(payment_method_customer_data_updated.datetime_updated).to eq("2022-01-01T21:28:37Z")
39
+ expect(payment_method_customer_data_updated.payment_method).to be_a(Braintree::VenmoAccount)
40
+ expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name).to eq("a-first-name")
41
+ expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name).to eq("a-last-name")
42
+ expect(payment_method_customer_data_updated.enriched_customer_data.fields_updated).to eq(["username"])
43
43
  end
44
44
  end
45
45
  end
@@ -14,18 +14,18 @@ describe Braintree::PaymentMethodNonceDetailsPayerInfo do
14
14
 
15
15
  describe "#initialize" do
16
16
  it "sets attributes" do
17
- payment_method_nonce_details_payer_info.billing_agreement_id.should == "billing-agreement-id"
18
- payment_method_nonce_details_payer_info.country_code.should == "US"
19
- payment_method_nonce_details_payer_info.email.should == "test@example.com"
20
- payment_method_nonce_details_payer_info.first_name.should == "First"
21
- payment_method_nonce_details_payer_info.last_name.should == "Last"
22
- payment_method_nonce_details_payer_info.payer_id.should == "payer-id"
17
+ expect(payment_method_nonce_details_payer_info.billing_agreement_id).to eq("billing-agreement-id")
18
+ expect(payment_method_nonce_details_payer_info.country_code).to eq("US")
19
+ expect(payment_method_nonce_details_payer_info.email).to eq("test@example.com")
20
+ expect(payment_method_nonce_details_payer_info.first_name).to eq("First")
21
+ expect(payment_method_nonce_details_payer_info.last_name).to eq("Last")
22
+ expect(payment_method_nonce_details_payer_info.payer_id).to eq("payer-id")
23
23
  end
24
24
  end
25
25
 
26
26
  describe "inspect" do
27
27
  it "prints the attributes" do
28
- payment_method_nonce_details_payer_info.inspect.should == %(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">)
28
+ expect(payment_method_nonce_details_payer_info.inspect).to eq(%(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">))
29
29
  end
30
30
  end
31
31
  end
@@ -22,30 +22,30 @@ describe Braintree::PaymentMethodNonceDetails do
22
22
 
23
23
  describe "#initialize" do
24
24
  it "sets attributes" do
25
- payment_method_nonce_details.bin.should == "bin"
26
- payment_method_nonce_details.card_type.should == "American Express"
27
- payment_method_nonce_details.expiration_month.should == "12"
28
- payment_method_nonce_details.expiration_year.should == "2025"
29
- payment_method_nonce_details.is_network_tokenized.should == true
30
- payment_method_nonce_details.last_two.should == "11"
31
- payment_method_nonce_details.payer_info.billing_agreement_id.should == "1234"
32
- payment_method_nonce_details.payer_info.country_code.should == "US"
33
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token.should == "a-bank-reference-token"
34
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4.should == "abcd"
35
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type.should == "ONE_OFF"
36
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id.should == "a-mp-customer-id"
25
+ expect(payment_method_nonce_details.bin).to eq("bin")
26
+ expect(payment_method_nonce_details.card_type).to eq("American Express")
27
+ expect(payment_method_nonce_details.expiration_month).to eq("12")
28
+ expect(payment_method_nonce_details.expiration_year).to eq("2025")
29
+ expect(payment_method_nonce_details.is_network_tokenized).to eq(true)
30
+ expect(payment_method_nonce_details.last_two).to eq("11")
31
+ expect(payment_method_nonce_details.payer_info.billing_agreement_id).to eq("1234")
32
+ expect(payment_method_nonce_details.payer_info.country_code).to eq("US")
33
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token).to eq("a-bank-reference-token")
34
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4).to eq("abcd")
35
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type).to eq("ONE_OFF")
36
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id).to eq("a-mp-customer-id")
37
37
  end
38
38
  end
39
39
 
40
40
  describe "inspect" do
41
41
  it "prints the attributes" do
42
- payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>)
42
+ expect(payment_method_nonce_details.inspect).to eq(%(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>))
43
43
  end
44
44
  end
45
45
 
46
46
  describe "is_network_tokenized" do
47
47
  it "is aliased to is_network_tokenized?" do
48
- payment_method_nonce_details.is_network_tokenized?.should == true
48
+ expect(payment_method_nonce_details.is_network_tokenized?).to eq(true)
49
49
  end
50
50
  end
51
51
  end
@@ -5,11 +5,11 @@ describe Braintree::PaymentMethod do
5
5
  it "handles an unknown payment method type" do
6
6
  unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
7
7
  http_instance = double(:get => unknown_response)
8
- Braintree::Http.stub(:new).and_return(http_instance)
8
+ allow(Braintree::Http).to receive(:new).and_return(http_instance)
9
9
  unknown_payment_method = Braintree::PaymentMethod.find("UNKNOWN_PAYMENT_METHOD_TOKEN")
10
10
 
11
- unknown_payment_method.token.should == 1234
12
- unknown_payment_method.default?.should be(true)
11
+ expect(unknown_payment_method.token).to eq(1234)
12
+ expect(unknown_payment_method.default?).to be(true)
13
13
  end
14
14
  end
15
15
 
@@ -17,27 +17,27 @@ describe Braintree::PaymentMethod do
17
17
  it "handles an unknown payment method type" do
18
18
  unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
19
19
  http_instance = double(:put => unknown_response)
20
- Braintree::Http.stub(:new).and_return(http_instance)
20
+ allow(Braintree::Http).to receive(:new).and_return(http_instance)
21
21
  result = Braintree::PaymentMethod.update(:unknown,
22
22
  {:options => {:make_default => true}})
23
23
 
24
- result.should be_success
25
- result.payment_method.token.should == 1234
26
- result.payment_method.should be_instance_of(Braintree::UnknownPaymentMethod)
24
+ expect(result).to be_success
25
+ expect(result.payment_method.token).to eq(1234)
26
+ expect(result.payment_method).to be_instance_of(Braintree::UnknownPaymentMethod)
27
27
  end
28
28
  end
29
29
 
30
30
  describe "delete" do
31
31
  let(:http_stub) { double("http_stub").as_null_object }
32
32
  it "accepts revoke_all_grants option with value true" do
33
- Braintree::Http.stub(:new).and_return http_stub
34
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
33
+ allow(Braintree::Http).to receive(:new).and_return http_stub
34
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
35
35
  Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => true})
36
36
  end
37
37
 
38
38
  it "accepts revoke_all_grants option with value false" do
39
- Braintree::Http.stub(:new).and_return http_stub
40
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
39
+ allow(Braintree::Http).to receive(:new).and_return http_stub
40
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
41
41
  Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => false})
42
42
  end
43
43
 
@@ -48,8 +48,8 @@ describe Braintree::PaymentMethod do
48
48
  end
49
49
 
50
50
  it "accepts just the token, revoke_all_grants is optional" do
51
- Braintree::Http.stub(:new).and_return http_stub
52
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
51
+ allow(Braintree::Http).to receive(:new).and_return http_stub
52
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
53
53
  Braintree::PaymentMethod.delete("some_token")
54
54
  end
55
55
  end
@@ -59,8 +59,8 @@ describe Braintree::PaymentMethod do
59
59
  now = Time.now
60
60
  paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
61
61
 
62
- paypal_account.created_at.should == now
63
- paypal_account.updated_at.should == now
62
+ expect(paypal_account.created_at).to eq(now)
63
+ expect(paypal_account.updated_at).to eq(now)
64
64
  end
65
65
  end
66
66
 
@@ -84,21 +84,21 @@ describe Braintree::PaymentMethod do
84
84
  end
85
85
 
86
86
  it "does not raise an error if token does not respond to strip" do
87
- Braintree::Http.stub(:new).and_return double.as_null_object
87
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
88
88
  expect do
89
89
  Braintree::PaymentMethod.grant(8675309, :allow_vaulting => false)
90
90
  end.to_not raise_error
91
91
  end
92
92
 
93
93
  it "accepts all options as hash map" do
94
- Braintree::Http.stub(:new).and_return double.as_null_object
94
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
95
95
  expect do
96
96
  Braintree::PaymentMethod.grant("$dummyToken", :allow_vaulting => false, :include_billing_postal_code => true)
97
97
  end.to_not raise_error
98
98
  end
99
99
 
100
100
  it "accepts only token as parameter" do
101
- Braintree::Http.stub(:new).and_return double.as_null_object
101
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
102
102
  expect do
103
103
  Braintree::PaymentMethod.grant("$dummyToken")
104
104
  end.to_not raise_error
@@ -126,7 +126,7 @@ describe Braintree::PaymentMethod do
126
126
  end
127
127
 
128
128
  it "does not raise an error if token does not respond to strip" do
129
- Braintree::Http.stub(:new).and_return double.as_null_object
129
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
130
130
  expect do
131
131
  Braintree::PaymentMethod.revoke(8675309)
132
132
  end.to_not raise_error
@@ -24,11 +24,11 @@ describe Braintree::PayPalAccount do
24
24
 
25
25
  describe "default?" do
26
26
  it "is true if the paypal account is the default payment method for the customer" do
27
- Braintree::PayPalAccount._new(:gateway, :default => true).default?.should == true
27
+ expect(Braintree::PayPalAccount._new(:gateway, :default => true).default?).to eq(true)
28
28
  end
29
29
 
30
30
  it "is false if the paypal account is not the default payment methodfor the customer" do
31
- Braintree::PayPalAccount._new(:gateway, :default => false).default?.should == false
31
+ expect(Braintree::PayPalAccount._new(:gateway, :default => false).default?).to eq(false)
32
32
  end
33
33
  end
34
34
 
@@ -37,8 +37,8 @@ describe Braintree::PayPalAccount do
37
37
  now = Time.now
38
38
  paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
39
39
 
40
- paypal_account.created_at.should == now
41
- paypal_account.updated_at.should == now
40
+ expect(paypal_account.created_at).to eq(now)
41
+ expect(paypal_account.updated_at).to eq(now)
42
42
  end
43
43
  end
44
44
  end
@@ -10,11 +10,11 @@ describe "Braintree::ResourceCollection" do
10
10
 
11
11
  count = 0
12
12
  collection.each_with_index do |item, index|
13
- item.should == values[index]
13
+ expect(item).to eq(values[index])
14
14
  count += 1
15
15
  end
16
16
 
17
- count.should == 5
17
+ expect(count).to eq(5)
18
18
  end
19
19
  end
20
20
 
@@ -25,7 +25,7 @@ describe "Braintree::ResourceCollection" do
25
25
  ids.map { |id| values[id] }
26
26
  end
27
27
 
28
- collection.first.should == nil
28
+ expect(collection.first).to eq(nil)
29
29
  end
30
30
 
31
31
  context "with results" do
@@ -38,11 +38,11 @@ describe "Braintree::ResourceCollection" do
38
38
  end
39
39
 
40
40
  it "returns the first occourence" do
41
- collection.first.should == "a"
41
+ expect(collection.first).to eq("a")
42
42
  end
43
43
 
44
44
  it "returns the first N occourences" do
45
- collection.first(4).should == ["a","b","c","d"]
45
+ expect(collection.first(4)).to eq(["a","b","c","d"])
46
46
  end
47
47
  end
48
48
  end
@@ -50,12 +50,12 @@ describe "Braintree::ResourceCollection" do
50
50
  describe "#ids" do
51
51
  it "returns a list of the resource collection ids" do
52
52
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
53
- collection.ids.should == [0,1,2,3,4]
53
+ expect(collection.ids).to eq([0,1,2,3,4])
54
54
  end
55
55
  end
56
56
 
57
57
  it "returns an empty array when the collection is empty" do
58
58
  collection = Braintree::ResourceCollection.new(:search_results => {:page_size => 2})
59
- collection.ids.should == []
59
+ expect(collection.ids).to eq([])
60
60
  end
61
61
  end
@@ -23,7 +23,7 @@ describe Braintree::SepaDirectDebitAccountNonceDetails do
23
23
 
24
24
  describe "inspect" do
25
25
  it "prints the attributes" do
26
- subject.inspect.should == %(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">)
26
+ expect(subject.inspect).to eq(%(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">))
27
27
  end
28
28
  end
29
29
  end
@@ -5,7 +5,7 @@ describe Braintree::SHA256Digest do
5
5
  it "returns the sha256 hmac of the input string (test case 6 from RFC 2202)" do
6
6
  key = "secret-key"
7
7
  message = "secret-message"
8
- Braintree::SHA256Digest.hexdigest(key, message).should == "68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc"
8
+ expect(Braintree::SHA256Digest.hexdigest(key, message)).to eq("68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc")
9
9
  end
10
10
  end
11
11
  end
@@ -11,13 +11,13 @@ describe Braintree::SignatureService do
11
11
  it "signs the data with its key" do
12
12
  service = Braintree::SignatureService.new("my_key", FakeDigest)
13
13
 
14
- service.sign(:foo => "foo bar").should == "foo=foo+bar_signed_with_my_key|foo=foo+bar"
14
+ expect(service.sign(:foo => "foo bar")).to eq("foo=foo+bar_signed_with_my_key|foo=foo+bar")
15
15
  end
16
16
  end
17
17
 
18
18
  describe "hash" do
19
19
  it "hashes the string with its key" do
20
- Braintree::SignatureService.new("my_key", FakeDigest).hash("foo").should == "foo_signed_with_my_key"
20
+ expect(Braintree::SignatureService.new("my_key", FakeDigest).hash("foo")).to eq("foo_signed_with_my_key")
21
21
  end
22
22
  end
23
23
  end