braintree 2.74.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +13 -7
  4. data/lib/braintree/account_updater_daily_report.rb +2 -2
  5. data/lib/braintree/ach_mandate.rb +2 -1
  6. data/lib/braintree/address/country_names.rb +4 -1
  7. data/lib/braintree/address.rb +30 -38
  8. data/lib/braintree/address_gateway.rb +12 -2
  9. data/lib/braintree/advanced_search.rb +8 -0
  10. data/lib/braintree/apple_pay.rb +29 -0
  11. data/lib/braintree/apple_pay_card.rb +28 -4
  12. data/lib/braintree/apple_pay_gateway.rb +37 -0
  13. data/lib/braintree/apple_pay_options.rb +19 -0
  14. data/lib/braintree/authorization_adjustment.rb +23 -0
  15. data/lib/braintree/base_module.rb +10 -0
  16. data/lib/braintree/bin_data.rb +33 -0
  17. data/lib/braintree/client_token.rb +3 -3
  18. data/lib/braintree/client_token_gateway.rb +3 -1
  19. data/lib/braintree/configuration.rb +57 -10
  20. data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
  21. data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
  22. data/lib/braintree/credentials_parser.rb +5 -1
  23. data/lib/braintree/credit_card.rb +53 -107
  24. data/lib/braintree/credit_card_gateway.rb +43 -30
  25. data/lib/braintree/credit_card_verification.rb +61 -21
  26. data/lib/braintree/credit_card_verification_gateway.rb +19 -6
  27. data/lib/braintree/credit_card_verification_search.rb +1 -1
  28. data/lib/braintree/customer.rb +51 -98
  29. data/lib/braintree/customer_gateway.rb +30 -23
  30. data/lib/braintree/customer_search.rb +1 -1
  31. data/lib/braintree/descriptor.rb +3 -1
  32. data/lib/braintree/disbursement.rb +24 -2
  33. data/lib/braintree/dispute/evidence.rb +24 -0
  34. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
  35. data/lib/braintree/dispute/status_history.rb +18 -0
  36. data/lib/braintree/dispute/transaction.rb +20 -0
  37. data/lib/braintree/dispute/transaction_details.rb +2 -1
  38. data/lib/braintree/dispute.rb +114 -10
  39. data/lib/braintree/dispute_gateway.rb +142 -0
  40. data/lib/braintree/dispute_search.rb +31 -0
  41. data/lib/braintree/document_upload.rb +37 -0
  42. data/lib/braintree/document_upload_gateway.rb +38 -0
  43. data/lib/braintree/enriched_customer_data.rb +21 -0
  44. data/lib/braintree/error_codes.rb +328 -109
  45. data/lib/braintree/error_result.rb +8 -1
  46. data/lib/braintree/exceptions.rb +5 -3
  47. data/lib/braintree/exchange_rate.rb +13 -0
  48. data/lib/braintree/exchange_rate_quote.rb +24 -0
  49. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  50. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  51. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  52. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  53. data/lib/braintree/facilitated_details.rb +21 -0
  54. data/lib/braintree/facilitator_details.rb +2 -1
  55. data/lib/braintree/gateway.rb +29 -11
  56. data/lib/braintree/google_pay_card.rb +61 -0
  57. data/lib/braintree/granted_payment_instrument_update.rb +23 -0
  58. data/lib/braintree/graphql_client.rb +34 -0
  59. data/lib/braintree/http.rb +81 -20
  60. data/lib/braintree/local_payment_completed.rb +23 -0
  61. data/lib/braintree/local_payment_expired.rb +21 -0
  62. data/lib/braintree/local_payment_funded.rb +22 -0
  63. data/lib/braintree/local_payment_reversed.rb +19 -0
  64. data/lib/braintree/merchant.rb +11 -4
  65. data/lib/braintree/merchant_account/address_details.rb +4 -1
  66. data/lib/braintree/merchant_account/business_details.rb +4 -1
  67. data/lib/braintree/merchant_account/funding_details.rb +6 -1
  68. data/lib/braintree/merchant_account/individual_details.rb +7 -2
  69. data/lib/braintree/merchant_account.rb +23 -10
  70. data/lib/braintree/merchant_account_gateway.rb +13 -1
  71. data/lib/braintree/merchant_gateway.rb +2 -2
  72. data/lib/braintree/modification.rb +1 -1
  73. data/lib/braintree/oauth_credentials.rb +5 -2
  74. data/lib/braintree/oauth_gateway.rb +8 -14
  75. data/lib/braintree/paginated_result.rb +3 -1
  76. data/lib/braintree/payment_instrument_type.rb +11 -11
  77. data/lib/braintree/payment_method.rb +20 -12
  78. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  79. data/lib/braintree/payment_method_gateway.rb +82 -54
  80. data/lib/braintree/payment_method_nonce.rb +22 -8
  81. data/lib/braintree/payment_method_nonce_details.rb +40 -0
  82. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  83. data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
  84. data/lib/braintree/payment_method_parser.rb +28 -0
  85. data/lib/braintree/paypal_account.rb +10 -1
  86. data/lib/braintree/plan.rb +25 -5
  87. data/lib/braintree/plan_gateway.rb +100 -0
  88. data/lib/braintree/processor_response_types.rb +7 -0
  89. data/lib/braintree/resource_collection.rb +8 -3
  90. data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
  91. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  92. data/lib/braintree/risk_data.rb +12 -2
  93. data/lib/braintree/samsung_pay_card.rb +83 -0
  94. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  95. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  96. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  97. data/lib/braintree/settlement_batch_summary.rb +2 -1
  98. data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
  99. data/lib/braintree/subscription/status_details.rb +8 -1
  100. data/lib/braintree/subscription.rb +56 -41
  101. data/lib/braintree/subscription_gateway.rb +25 -2
  102. data/lib/braintree/successful_result.rb +23 -1
  103. data/lib/braintree/test/authentication_id.rb +21 -0
  104. data/lib/braintree/test/credit_card.rb +13 -0
  105. data/lib/braintree/test/nonce.rb +28 -20
  106. data/lib/braintree/test/transaction_amounts.rb +1 -0
  107. data/lib/braintree/three_d_secure_info.rb +34 -2
  108. data/lib/braintree/transaction/address_details.rb +24 -4
  109. data/lib/braintree/transaction/apple_pay_details.rb +20 -2
  110. data/lib/braintree/transaction/credit_card_details.rb +45 -6
  111. data/lib/braintree/transaction/customer_details.rb +8 -1
  112. data/lib/braintree/transaction/disbursement_details.rb +6 -1
  113. data/lib/braintree/transaction/google_pay_details.rb +41 -0
  114. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  115. data/lib/braintree/transaction/installment.rb +28 -0
  116. data/lib/braintree/transaction/local_payment_details.rb +24 -0
  117. data/lib/braintree/transaction/paypal_details.rb +26 -4
  118. data/lib/braintree/transaction/paypal_here_details.rb +23 -0
  119. data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
  120. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  121. data/lib/braintree/transaction/status_details.rb +5 -1
  122. data/lib/braintree/transaction/subscription_details.rb +4 -1
  123. data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
  124. data/lib/braintree/transaction/venmo_account_details.rb +5 -1
  125. data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
  126. data/lib/braintree/transaction.rb +201 -188
  127. data/lib/braintree/transaction_gateway.rb +124 -30
  128. data/lib/braintree/transaction_line_item.rb +40 -0
  129. data/lib/braintree/transaction_line_item_gateway.rb +19 -0
  130. data/lib/braintree/transaction_review.rb +18 -0
  131. data/lib/braintree/transaction_search.rb +6 -3
  132. data/lib/braintree/unknown_payment_method.rb +3 -2
  133. data/lib/braintree/us_bank_account.rb +24 -8
  134. data/lib/braintree/us_bank_account_gateway.rb +0 -1
  135. data/lib/braintree/us_bank_account_verification.rb +81 -0
  136. data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
  137. data/lib/braintree/us_bank_account_verification_search.rb +19 -0
  138. data/lib/braintree/util.rb +79 -9
  139. data/lib/braintree/validation_error.rb +13 -3
  140. data/lib/braintree/validation_error_collection.rb +2 -1
  141. data/lib/braintree/venmo_account.rb +11 -4
  142. data/lib/braintree/venmo_profile_data.rb +23 -0
  143. data/lib/braintree/version.rb +2 -2
  144. data/lib/braintree/visa_checkout_card.rb +29 -13
  145. data/lib/braintree/webhook_notification.rb +66 -26
  146. data/lib/braintree/webhook_notification_gateway.rb +5 -3
  147. data/lib/braintree/webhook_testing.rb +2 -2
  148. data/lib/braintree/webhook_testing_gateway.rb +721 -55
  149. data/lib/braintree/xml/generator.rb +6 -4
  150. data/lib/braintree/xml/parser.rb +22 -35
  151. data/lib/braintree/xml/rexml.rb +4 -5
  152. data/lib/braintree.rb +60 -22
  153. data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
  154. data/spec/fixtures/files/bt_logo.png +0 -0
  155. data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
  156. data/spec/fixtures/files/malformed_pdf.pdf +1 -0
  157. data/spec/fixtures/files/too_long.pdf +0 -0
  158. data/spec/integration/braintree/add_on_spec.rb +3 -3
  159. data/spec/integration/braintree/address_spec.rb +30 -113
  160. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  161. data/spec/integration/braintree/apple_pay_spec.rb +63 -0
  162. data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
  163. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
  164. data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
  165. data/spec/integration/braintree/credit_card_spec.rb +460 -615
  166. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  167. data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
  168. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  169. data/spec/integration/braintree/customer_spec.rb +810 -498
  170. data/spec/integration/braintree/discount_spec.rb +1 -1
  171. data/spec/integration/braintree/dispute_search_spec.rb +167 -0
  172. data/spec/integration/braintree/dispute_spec.rb +333 -0
  173. data/spec/integration/braintree/document_upload_spec.rb +87 -0
  174. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  175. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  176. data/spec/integration/braintree/graphql_client_spec.rb +72 -0
  177. data/spec/integration/braintree/http_spec.rb +12 -4
  178. data/spec/integration/braintree/merchant_account_spec.rb +74 -26
  179. data/spec/integration/braintree/merchant_spec.rb +39 -13
  180. data/spec/integration/braintree/oauth_spec.rb +18 -25
  181. data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
  182. data/spec/integration/braintree/payment_method_spec.rb +882 -300
  183. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
  184. data/spec/integration/braintree/paypal_account_spec.rb +32 -31
  185. data/spec/integration/braintree/plan_spec.rb +82 -0
  186. data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
  187. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
  188. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  189. data/spec/integration/braintree/subscription_spec.rb +274 -180
  190. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  191. data/spec/integration/braintree/test_transaction_spec.rb +18 -18
  192. data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
  193. data/spec/integration/braintree/transaction_search_spec.rb +280 -152
  194. data/spec/integration/braintree/transaction_spec.rb +3709 -1175
  195. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
  196. data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
  197. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
  198. data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
  199. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  200. data/spec/integration/spec_helper.rb +27 -6
  201. data/spec/oauth_test_helper.rb +1 -1
  202. data/spec/script/httpsd.rb +6 -6
  203. data/spec/spec_helper.rb +26 -23
  204. data/spec/unit/braintree/address_spec.rb +1 -9
  205. data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
  206. data/spec/unit/braintree/client_token_spec.rb +2 -2
  207. data/spec/unit/braintree/configuration_spec.rb +108 -33
  208. data/spec/unit/braintree/credit_card_spec.rb +62 -33
  209. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
  210. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  211. data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
  212. data/spec/unit/braintree/customer_spec.rb +107 -27
  213. data/spec/unit/braintree/disbursement_spec.rb +59 -7
  214. data/spec/unit/braintree/dispute_search_spec.rb +66 -0
  215. data/spec/unit/braintree/dispute_spec.rb +472 -8
  216. data/spec/unit/braintree/document_upload_spec.rb +35 -0
  217. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  218. data/spec/unit/braintree/error_result_spec.rb +5 -5
  219. data/spec/unit/braintree/errors_spec.rb +8 -8
  220. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  221. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  222. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  223. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  224. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  225. data/spec/unit/braintree/http_spec.rb +93 -5
  226. data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
  227. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  228. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  229. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  230. data/spec/unit/braintree/modification_spec.rb +1 -1
  231. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  232. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  233. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  234. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  235. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  236. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  237. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  238. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  239. data/spec/unit/braintree/risk_data_spec.rb +40 -6
  240. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  241. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  242. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  243. data/spec/unit/braintree/subscription_spec.rb +2 -2
  244. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  245. data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
  246. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
  247. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  248. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  249. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  250. data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
  251. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  252. data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
  253. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  254. data/spec/unit/braintree/transaction_spec.rb +171 -55
  255. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
  256. data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
  257. data/spec/unit/braintree/util_spec.rb +162 -19
  258. data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
  259. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  260. data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
  261. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  262. data/spec/unit/braintree/xml_spec.rb +31 -24
  263. data/spec/unit/braintree_spec.rb +1 -0
  264. metadata +290 -198
  265. data/README.rdoc +0 -93
  266. data/lib/braintree/amex_express_checkout_card.rb +0 -26
  267. data/lib/braintree/android_pay_card.rb +0 -35
  268. data/lib/braintree/coinbase_account.rb +0 -25
  269. data/lib/braintree/europe_bank_account.rb +0 -34
  270. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  271. data/lib/braintree/ideal_payment.rb +0 -46
  272. data/lib/braintree/ideal_payment_gateway.rb +0 -18
  273. data/lib/braintree/masterpass_card.rb +0 -66
  274. data/lib/braintree/settlement_batch.rb +0 -0
  275. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
  276. data/lib/braintree/transaction/android_pay_details.rb +0 -17
  277. data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
  278. data/lib/braintree/transparent_redirect.rb +0 -40
  279. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  280. data/spec/hacks/tcp_socket.rb +0 -18
  281. data/spec/httpsd.pid +0 -1
  282. data/spec/integration/braintree/coinbase_spec.rb +0 -31
  283. data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
  284. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  285. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  286. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::SepaDirectDebitAccountDetails do
4
+ describe "initialize" do
5
+ let(:params) do
6
+ {
7
+ bank_reference_token: "a-reference-token",
8
+ capture_id: "a-capture-id",
9
+ debug_id: "a-debug-id",
10
+ global_id: "a-global-id",
11
+ last_4: "1234",
12
+ mandate_type: "ONE_OFF",
13
+ merchant_or_partner_customer_id: "12312312343",
14
+ paypal_v2_order_id: "a-paypal-v2-order-id",
15
+ refund_from_transaction_fee_amount: "2.34",
16
+ refund_from_transaction_fee_currency_iso_code: "EUR",
17
+ refund_id: "a-refund-id",
18
+ settlement_type: "INSTANT",
19
+ token: "a-token",
20
+ transaction_fee_amount: "12.34",
21
+ transaction_fee_currency_iso_code: "EUR",
22
+ }
23
+ end
24
+
25
+ subject do
26
+ described_class.new(params)
27
+ end
28
+
29
+ it "sets all fields" do
30
+ is_expected.to have_attributes(**params)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,111 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::TransactionGateway do
4
+ describe "Transaction Gateway" do
5
+ let(:gateway) do
6
+ config = Braintree::Configuration.new(
7
+ :merchant_id => "merchant_id",
8
+ :public_key => "public_key",
9
+ :private_key => "private_key",
10
+ )
11
+ Braintree::Gateway.new(config)
12
+ end
13
+
14
+ it "creates a transactionGateway gateway" do
15
+ result = Braintree::TransactionGateway.new(gateway)
16
+
17
+ result.inspect.should include("merchant_id")
18
+ result.inspect.should include("public_key")
19
+ result.inspect.should include("private_key")
20
+ end
21
+
22
+ describe "self.create" do
23
+ it "raises an exception if attributes contain an invalid key" do
24
+ expect do
25
+ transaction = Braintree::TransactionGateway.new(gateway)
26
+ transaction.create(:invalid_key => "val")
27
+ end.to raise_error(ArgumentError, "invalid keys: invalid_key")
28
+ end
29
+ end
30
+
31
+ it "creates a transaction gateway signature" do
32
+ expect(Braintree::TransactionGateway._create_signature).to match([
33
+ :amount, :billing_address_id, :channel, :customer_id, :device_data, :discount_amount,
34
+ :merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token,
35
+ :product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
36
+ :shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
37
+ :shared_shipping_address_id, :shipping_address_id, :shipping_amount,
38
+ :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,
39
+ :three_d_secure_token, :transaction_source, :type, :venmo_sdk_payment_method_code,
40
+ :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
41
+ {:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
42
+ {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
43
+ {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
44
+ {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
45
+ {
46
+ :billing => Braintree::AddressGateway._shared_signature
47
+ },
48
+ {
49
+ :shipping => Braintree::AddressGateway._shared_signature + [:shipping_method],
50
+ },
51
+ {
52
+ :three_d_secure_pass_thru => [
53
+ :eci_flag,
54
+ :cavv,
55
+ :xid,
56
+ :three_d_secure_version,
57
+ :authentication_response,
58
+ :directory_response,
59
+ :cavv_algorithm,
60
+ :ds_transaction_id,
61
+ ]
62
+ },
63
+ {:options => [
64
+ :hold_in_escrow,
65
+ :store_in_vault,
66
+ :store_in_vault_on_success,
67
+ :submit_for_settlement,
68
+ :add_billing_address_to_payment_method,
69
+ :store_shipping_address_in_vault,
70
+ :venmo_sdk_session,
71
+ :payee_id,
72
+ :payee_email,
73
+ :skip_advanced_fraud_checking,
74
+ :skip_avs,
75
+ :skip_cvv,
76
+ {:paypal => [:custom_field, :payee_id, :payee_email, :description, {:supplementary_data => :_any_key_}]},
77
+ {:three_d_secure => [:required]},
78
+ {:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
79
+ {:venmo => [:profile_id]},
80
+ {:credit_card => [:account_type]},
81
+ ]
82
+ },
83
+ {:external_vault => [
84
+ :status,
85
+ :previous_network_transaction_id,
86
+ ]},
87
+ {:custom_fields => :_any_key_},
88
+ {:descriptor => [:name, :phone, :url]},
89
+ {:paypal_account => [:email, :token, :paypal_data, :payee_id, :payee_email, :payer_id, :payment_id]},
90
+ {:industry => [
91
+ :industry_type,
92
+ {:data => [
93
+ :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax,
94
+ :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number,
95
+ :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone,
96
+ {:legs => [
97
+ :conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time,
98
+ :arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions,
99
+ ]},
100
+ {:additional_charges => [
101
+ :kind, :amount,
102
+ ]},
103
+ ]},
104
+ ]},
105
+ {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
106
+ {:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
107
+ {:installments => [:count]},
108
+ ])
109
+ end
110
+ end
111
+ end
@@ -1,19 +1,19 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Braintree::TransactionSearch do
4
- it "overrides previous 'is' with new 'is' for the same field" do
5
- search = Braintree::TransactionSearch.new
6
- search.billing_company.is "one"
7
- search.billing_company.is "two"
8
- search.to_hash.should == {:billing_company => {:is => "two"}}
9
- end
4
+ it "overrides previous 'is' with new 'is' for the same field" do
5
+ search = Braintree::TransactionSearch.new
6
+ search.billing_company.is "one"
7
+ search.billing_company.is "two"
8
+ search.to_hash.should == {:billing_company => {:is => "two"}}
9
+ end
10
10
 
11
- it "overrides previous 'in' with new 'in' for the same field" do
12
- search = Braintree::TransactionSearch.new
13
- search.status.in Braintree::Transaction::Status::Authorized
14
- search.status.in Braintree::Transaction::Status::SubmittedForSettlement
15
- search.to_hash.should == {:status => [Braintree::Transaction::Status::SubmittedForSettlement]}
16
- end
11
+ it "overrides previous 'in' with new 'in' for the same field" do
12
+ search = Braintree::TransactionSearch.new
13
+ search.status.in Braintree::Transaction::Status::Authorized
14
+ search.status.in Braintree::Transaction::Status::SubmittedForSettlement
15
+ search.to_hash.should == {:status => [Braintree::Transaction::Status::SubmittedForSettlement]}
16
+ end
17
17
 
18
18
  it "raises if the operator 'is' is left off" do
19
19
  search = Braintree::TransactionSearch.new
@@ -17,45 +17,38 @@ describe Braintree::Transaction do
17
17
  end
18
18
  end
19
19
 
20
- describe "self.create_from_transparent_redirect" do
21
- it "raises an exception if the query string is forged" do
22
- expect do
23
- Braintree::Transaction.create_from_transparent_redirect("http_status=200&forged=query_string")
24
- end.to raise_error(Braintree::ForgedQueryString)
25
- end
26
- end
27
-
28
20
  describe "self.find" do
29
21
  it "raises error if passed empty string" do
30
22
  expect do
31
23
  Braintree::Transaction.find("")
32
- end.to raise_error(ArgumentError)
24
+ end.to raise_error(ArgumentError, "id can not be empty")
33
25
  end
34
26
 
35
27
  it "raises error if passed empty string wth space" do
36
28
  expect do
37
29
  Braintree::Transaction.find(" ")
38
- end.to raise_error(ArgumentError)
30
+ end.to raise_error(ArgumentError, "id can not be empty")
39
31
  end
40
32
 
41
33
  it "raises error if passed nil" do
42
34
  expect do
43
35
  Braintree::Transaction.find(nil)
44
- end.to raise_error(ArgumentError)
36
+ end.to raise_error(ArgumentError, "id can not be empty")
45
37
  end
46
38
  end
47
39
 
48
- describe "self.create_transaction_url" do
49
- it "returns the url" do
50
- config = Braintree::Configuration.instantiate
51
- Braintree::Transaction.create_transaction_url.should == "http#{config.ssl? ? 's' : ''}://#{config.server}:#{config.port}/merchants/integration_merchant_id/transactions/all/create_via_transparent_redirect_request"
40
+ describe "self.submit_for_settlement" do
41
+ it "raises an ArgumentError if transaction_id is an invalid format" do
42
+ expect do
43
+ Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
44
+ end.to raise_error(ArgumentError, "transaction_id is invalid")
52
45
  end
53
46
  end
54
47
 
55
- describe "self.submit_for_settlement" do
48
+ describe "self.adjust_authorization" do
56
49
  it "raises an ArgumentError if transaction_id is an invalid format" do
57
50
  expect do
58
- Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
51
+ Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
59
52
  end.to raise_error(ArgumentError, "transaction_id is invalid")
60
53
  end
61
54
  end
@@ -81,7 +74,7 @@ describe Braintree::Transaction do
81
74
  :website => "lednerllc.com",
82
75
  :phone => "1-999-652-4189 x56883",
83
76
  :fax => "012-161-8055"
84
- }
77
+ },
85
78
  )
86
79
  transaction.customer_details.id.should == "123"
87
80
  transaction.customer_details.first_name.should == "Adam"
@@ -103,10 +96,10 @@ describe Braintree::Transaction do
103
96
  :settlement_currency_exchange_rate => "1",
104
97
  :funds_held => false,
105
98
  :success => true
106
- }
99
+ },
107
100
  )
108
101
  disbursement = transaction.disbursement_details
109
- disbursement.disbursement_date.should == "2013-04-03"
102
+ disbursement.disbursement_date.should == Date.parse("2013-04-03")
110
103
  disbursement.settlement_amount.should == "120.00"
111
104
  disbursement.settlement_currency_iso_code.should == "USD"
112
105
  disbursement.settlement_currency_exchange_rate.should == "1"
@@ -134,7 +127,7 @@ describe Braintree::Transaction do
134
127
  :product_id => "Unknown",
135
128
  :country_of_issuance => "Narnia",
136
129
  :issuing_bank => "Mr Tumnus"
137
- }
130
+ },
138
131
  )
139
132
  transaction.credit_card_details.token.should == "mzg2"
140
133
  transaction.credit_card_details.bin.should == "411111"
@@ -154,6 +147,48 @@ describe Braintree::Transaction do
154
147
  transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
155
148
  end
156
149
 
150
+ it "sets up network token attributes in network_token_details" do
151
+ transaction = Braintree::Transaction._new(
152
+ :gateway,
153
+ :network_token => {
154
+ :token => "mzg2",
155
+ :bin => "411111",
156
+ :last_4 => "1111",
157
+ :card_type => "Visa",
158
+ :expiration_month => "08",
159
+ :expiration_year => "2009",
160
+ :customer_location => "US",
161
+ :prepaid => "Yes",
162
+ :healthcare => "Yes",
163
+ :durbin_regulated => "Yes",
164
+ :debit => "Yes",
165
+ :commercial => "No",
166
+ :payroll => "Unknown",
167
+ :product_id => "Unknown",
168
+ :country_of_issuance => "Narnia",
169
+ :issuing_bank => "Mr Tumnus",
170
+ :is_network_tokenized => true
171
+ },
172
+ )
173
+ transaction.network_token_details.token.should == "mzg2"
174
+ transaction.network_token_details.bin.should == "411111"
175
+ transaction.network_token_details.last_4.should == "1111"
176
+ transaction.network_token_details.card_type.should == "Visa"
177
+ transaction.network_token_details.expiration_month.should == "08"
178
+ transaction.network_token_details.expiration_year.should == "2009"
179
+ transaction.network_token_details.customer_location.should == "US"
180
+ transaction.network_token_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
181
+ transaction.network_token_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
182
+ transaction.network_token_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
183
+ transaction.network_token_details.debit.should == Braintree::CreditCard::Debit::Yes
184
+ transaction.network_token_details.commercial.should == Braintree::CreditCard::Commercial::No
185
+ transaction.network_token_details.payroll.should == Braintree::CreditCard::Payroll::Unknown
186
+ transaction.network_token_details.product_id.should == Braintree::CreditCard::ProductId::Unknown
187
+ transaction.network_token_details.country_of_issuance.should == "Narnia"
188
+ transaction.network_token_details.issuing_bank.should == "Mr Tumnus"
189
+ transaction.network_token_details.is_network_tokenized?.should == true
190
+ end
191
+
157
192
  it "sets up three_d_secure_info" do
158
193
  transaction = Braintree::Transaction._new(
159
194
  :gateway,
@@ -162,7 +197,7 @@ describe Braintree::Transaction do
162
197
  :liability_shifted => true,
163
198
  :liability_shift_possible => true,
164
199
  :status => "authenticate_successful",
165
- }
200
+ },
166
201
  )
167
202
 
168
203
  transaction.three_d_secure_info.enrolled.should == "Y"
@@ -171,33 +206,14 @@ describe Braintree::Transaction do
171
206
  transaction.three_d_secure_info.liability_shift_possible.should == true
172
207
  end
173
208
 
174
- it "sets up ideal_payment_details" do
175
- transaction = Braintree::Transaction._new(
176
- :gateway,
177
- :ideal_payment => {
178
- :ideal_payment_id => "idealpayment_abc_123",
179
- :ideal_transaction_id => "1150000008857321",
180
- :masked_iban => "12************7890",
181
- :bic => "RABONL2U",
182
- :image_url => "http://www.example.com/ideal.png"
183
- }
184
- )
185
-
186
- transaction.ideal_payment_details.ideal_payment_id.should == "idealpayment_abc_123"
187
- transaction.ideal_payment_details.ideal_transaction_id.should == "1150000008857321"
188
- transaction.ideal_payment_details.masked_iban.should == "12************7890"
189
- transaction.ideal_payment_details.bic.should == "RABONL2U"
190
- transaction.ideal_payment_details.image_url.should == "http://www.example.com/ideal.png"
191
- end
192
-
193
209
  it "sets up history attributes in status_history" do
194
210
  time = Time.utc(2010,1,14)
195
211
  transaction = Braintree::Transaction._new(
196
212
  :gateway,
197
213
  :status_history => [
198
- { :timestamp => time, :amount => "12.00", :transaction_source => "API",
199
- :user => "larry", :status => Braintree::Transaction::Status::Authorized },
200
- { :timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
214
+ {:timestamp => time, :amount => "12.00", :transaction_source => "API",
215
+ :user => "larry", :status => Braintree::Transaction::Status::Authorized},
216
+ {:timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
201
217
  :user => "curly", :status => "scheduled_for_settlement"}
202
218
  ])
203
219
  transaction.status_history.size.should == 2
@@ -209,16 +225,37 @@ describe Braintree::Transaction do
209
225
  transaction.status_history[1].user.should == "curly"
210
226
  end
211
227
 
228
+ it "sets up authorization_adjustments" do
229
+ timestamp = Time.utc(2010,1,14)
230
+ transaction = Braintree::Transaction._new(
231
+ :gateway,
232
+ :authorization_adjustments => [
233
+ {:timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true},
234
+ {:timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false},
235
+ ])
236
+ transaction.authorization_adjustments.size.should == 2
237
+ transaction.authorization_adjustments[0].amount.should == "12.00"
238
+ transaction.authorization_adjustments[0].success.should == true
239
+ transaction.authorization_adjustments[0].timestamp.should == timestamp
240
+ transaction.authorization_adjustments[0].processor_response_code.should == "1000"
241
+ transaction.authorization_adjustments[0].processor_response_text.should == "Approved"
242
+ transaction.authorization_adjustments[1].amount.should == "12.34"
243
+ transaction.authorization_adjustments[1].success.should == false
244
+ transaction.authorization_adjustments[1].timestamp.should == timestamp
245
+ transaction.authorization_adjustments[1].processor_response_code.should == "3000"
246
+ transaction.authorization_adjustments[1].processor_response_text.should == "Processor Network Unavailable - Try Again"
247
+ end
248
+
212
249
  it "handles receiving custom as an empty string" do
213
250
  transaction = Braintree::Transaction._new(
214
251
  :gateway,
215
- :custom => "\n "
252
+ :custom => "\n ",
216
253
  )
217
254
  end
218
255
 
219
256
  it "accepts amount as either a String or a BigDecimal" do
220
- Braintree::Transaction._new(:gateway, :amount => "12.34").amount.should == BigDecimal.new("12.34")
221
- Braintree::Transaction._new(:gateway, :amount => BigDecimal.new("12.34")).amount.should == BigDecimal.new("12.34")
257
+ Braintree::Transaction._new(:gateway, :amount => "12.34").amount.should == BigDecimal("12.34")
258
+ Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
222
259
  end
223
260
 
224
261
  it "blows up if amount is not a string or BigDecimal" do
@@ -230,23 +267,84 @@ describe Braintree::Transaction do
230
267
  it "handles nil risk_data" do
231
268
  transaction = Braintree::Transaction._new(
232
269
  :gateway,
233
- :risk_data => nil
270
+ :risk_data => nil,
234
271
  )
235
272
  transaction.risk_data.should be_nil
236
273
  end
274
+
275
+ it "accepts network_transaction_id" do
276
+ transaction = Braintree::Transaction._new(
277
+ :gateway,
278
+ :network_transaction_id => "123456789012345",
279
+ )
280
+ transaction.network_transaction_id.should == "123456789012345"
281
+ end
282
+
283
+ it "accepts ach_return_code" do
284
+ transaction = Braintree::Transaction._new(
285
+ :gateway,
286
+ :ach_return_code => "R01",
287
+ )
288
+ expect(transaction.ach_return_code).to eq("R01")
289
+ end
290
+
291
+ it "accepts network_response code and network_response_text" do
292
+ transaction = Braintree::Transaction._new(
293
+ :gateway,
294
+ :network_response_code => "00",
295
+ :network_response_text => "Successful approval/completion or V.I.P. PIN verification is successful",
296
+ )
297
+ expect(transaction.network_response_code).to eq("00")
298
+ expect(transaction.network_response_text).to eq("Successful approval/completion or V.I.P. PIN verification is successful")
299
+ end
300
+
301
+ it "accepts merchant_advice_code and merchant_advice_text" do
302
+ transaction = Braintree::Transaction._new(
303
+ :gateway,
304
+ :merchant_advice_code => "01",
305
+ :merchant_advice_code_text => "New account information available",
306
+ )
307
+ expect(transaction.merchant_advice_code).to eq("01")
308
+ expect(transaction.merchant_advice_code_text).to eq("New account information available")
309
+ end
310
+
311
+ it "accepts sepa_direct_debit_return_code" do
312
+ transaction = Braintree::Transaction._new(
313
+ :gateway,
314
+ :sepa_direct_debit_return_code => "AM04",
315
+ )
316
+ expect(transaction.sepa_direct_debit_return_code).to eq("AM04")
317
+ end
318
+
319
+ it "accepts sepa_direct_debit_account_details" do
320
+ transaction = Braintree::Transaction._new(
321
+ :gateway,
322
+ :id => "123",
323
+ :type => "sale",
324
+ :amount => "12.34",
325
+ :status => "settled",
326
+ :sepa_debit_account_detail => {
327
+ :token => "1234",
328
+ },
329
+ )
330
+ details = transaction.sepa_direct_debit_account_details
331
+ details.token.should == "1234"
332
+ end
237
333
  end
238
334
 
239
335
  describe "inspect" do
240
- it "includes the id, type, amount, and status first" do
336
+ it "includes the id, type, amount, status, and processed_with_network_token?" do
241
337
  transaction = Braintree::Transaction._new(
242
338
  :gateway,
243
339
  :id => "1234",
244
340
  :type => "sale",
245
341
  :amount => "100.00",
246
- :status => Braintree::Transaction::Status::Authorized
342
+ :status => Braintree::Transaction::Status::Authorized,
343
+ :processed_with_network_token => false,
247
344
  )
248
345
  output = transaction.inspect
249
346
  output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
347
+ output.should include(%Q(processed_with_network_token?: false))
250
348
  end
251
349
  end
252
350
 
@@ -300,8 +398,8 @@ describe Braintree::Transaction do
300
398
  end
301
399
 
302
400
  describe "sale" do
303
- let(:mock_response) { {:transaction => {}}}
304
- let(:http_stub) { double('http_stub').as_null_object }
401
+ let(:mock_response) { {:transaction => {}} }
402
+ let(:http_stub) { double("http_stub").as_null_object }
305
403
 
306
404
  RSpec::Matchers.define :skip_advanced_fraud_check_value_is do |value|
307
405
  match { |params| params[:transaction][:options][:skip_advanced_fraud_checking] == value }
@@ -319,7 +417,7 @@ describe Braintree::Transaction do
319
417
  },
320
418
  :options => {
321
419
  :skip_advanced_fraud_checking => true
322
- }
420
+ },
323
421
  )
324
422
  end
325
423
 
@@ -335,7 +433,7 @@ describe Braintree::Transaction do
335
433
  },
336
434
  :options => {
337
435
  :skip_advanced_fraud_checking => false
338
- }
436
+ },
339
437
  )
340
438
  end
341
439
 
@@ -351,9 +449,27 @@ describe Braintree::Transaction do
351
449
  },
352
450
  :options => {
353
451
  :submit_for_settlement => false
354
- }
452
+ },
355
453
  )
356
454
  end
357
455
  end
358
456
 
457
+ describe "processed_with_network_token?" do
458
+ it "is true if the transaction was processed with a network token" do
459
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => true)
460
+ transaction.processed_with_network_token?.should == true
461
+ end
462
+
463
+ it "is false if the transaction was not processed with a network token" do
464
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => false)
465
+ transaction.processed_with_network_token?.should == false
466
+ end
467
+ end
468
+
469
+ describe "gateway rejection reason" do
470
+ it "verifies excessive_retry mapping" do
471
+ transaction = Braintree::Transaction._new(:gateway, :gateway_rejection_reason => "excessive_retry")
472
+ transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry
473
+ end
474
+ end
359
475
  end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ module Braintree
4
+ describe UsBankAccountVerificationSearch do
5
+ context "verification method" do
6
+ it "allows All verification methods" do
7
+ search = UsBankAccountVerificationSearch.new
8
+
9
+ lambda do
10
+ search.verification_method.in(
11
+ *Braintree::UsBankAccountVerification::VerificationMethod::All,
12
+ )
13
+ end.should_not raise_error
14
+ end
15
+ end
16
+
17
+ context "id" do
18
+ it "is" do
19
+ search = UsBankAccountVerificationSearch.new
20
+ search.id.is "v_id"
21
+
22
+ search.to_hash.should == {:id => {:is => "v_id"}}
23
+ end
24
+ end
25
+
26
+ context "ids" do
27
+ it "correctly builds a hash with ids" do
28
+ search = UsBankAccountVerificationSearch.new
29
+ search.ids.in("id1", "id2")
30
+
31
+ search.to_hash.should == {:ids => ["id1", "id2"]}
32
+ end
33
+ end
34
+
35
+ context "account_holder_name" do
36
+ it "is" do
37
+ search = UsBankAccountVerificationSearch.new
38
+ search.account_holder_name.is "v_account_holder_name"
39
+
40
+ search.to_hash.should == {:account_holder_name => {:is => "v_account_holder_name"}}
41
+ end
42
+ end
43
+
44
+ context "created_at" do
45
+ it "is a range node" do
46
+ search = UsBankAccountVerificationSearch.new
47
+ search.created_at.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
48
+ end
49
+ end
50
+
51
+ context "account number" do
52
+ it "uses ends_with" do
53
+ search = UsBankAccountVerificationSearch.new
54
+ search.account_number.ends_with "1234"
55
+
56
+ search.to_hash.should == {:account_number => {:ends_with => "1234"}}
57
+ end
58
+ end
59
+ end
60
+ end