braintree 4.13.0 → 4.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/credit_card.rb +13 -0
  3. data/lib/braintree/credit_card_gateway.rb +15 -3
  4. data/lib/braintree/payment_method_gateway.rb +15 -3
  5. data/lib/braintree/test/nonce.rb +1 -0
  6. data/lib/braintree/test/venmo_sdk.rb +2 -0
  7. data/lib/braintree/transaction/credit_card_details.rb +3 -0
  8. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  9. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  10. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  11. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  12. data/lib/braintree/transaction/us_bank_account_details.rb +1 -0
  13. data/lib/braintree/transaction.rb +7 -4
  14. data/lib/braintree/transaction_gateway.rb +15 -3
  15. data/lib/braintree/transaction_search.rb +6 -5
  16. data/lib/braintree/version.rb +1 -1
  17. data/lib/braintree/webhook_notification.rb +1 -0
  18. data/lib/braintree/webhook_testing_gateway.rb +17 -0
  19. data/lib/braintree.rb +3 -0
  20. data/spec/integration/braintree/add_on_spec.rb +9 -9
  21. data/spec/integration/braintree/address_spec.rb +69 -69
  22. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  23. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  24. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  25. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  26. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  27. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  28. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  29. data/spec/integration/braintree/customer_spec.rb +313 -313
  30. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  31. data/spec/integration/braintree/discount_spec.rb +9 -9
  32. data/spec/integration/braintree/dispute_spec.rb +87 -87
  33. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  34. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  35. data/spec/integration/braintree/http_spec.rb +28 -28
  36. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  37. data/spec/integration/braintree/merchant_spec.rb +103 -103
  38. data/spec/integration/braintree/oauth_spec.rb +61 -61
  39. data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
  40. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  41. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
  42. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  43. data/spec/integration/braintree/plan_spec.rb +15 -15
  44. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  45. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  46. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  47. data/spec/integration/braintree/subscription_spec.rb +364 -364
  48. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  49. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  50. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  51. data/spec/integration/braintree/transaction_search_spec.rb +198 -165
  52. data/spec/integration/braintree/transaction_spec.rb +1319 -1151
  53. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  54. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  55. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  56. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  57. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  58. data/spec/spec_helper.rb +9 -8
  59. data/spec/unit/braintree/address_spec.rb +8 -8
  60. data/spec/unit/braintree/base_module_spec.rb +4 -4
  61. data/spec/unit/braintree/client_token_spec.rb +2 -2
  62. data/spec/unit/braintree/configuration_spec.rb +57 -57
  63. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  64. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  65. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  66. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  67. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  68. data/spec/unit/braintree/customer_spec.rb +41 -40
  69. data/spec/unit/braintree/digest_spec.rb +5 -5
  70. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  71. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  72. data/spec/unit/braintree/dispute_spec.rb +56 -56
  73. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  74. data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
  75. data/spec/unit/braintree/error_result_spec.rb +5 -5
  76. data/spec/unit/braintree/errors_spec.rb +9 -9
  77. data/spec/unit/braintree/http_spec.rb +8 -8
  78. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  79. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  80. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  81. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  82. data/spec/unit/braintree/modification_spec.rb +1 -1
  83. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  84. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  85. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  86. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  87. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  88. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  89. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  90. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  91. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  92. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  93. data/spec/unit/braintree/subscription_spec.rb +8 -8
  94. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  95. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  96. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  97. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  98. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  99. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  100. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  101. data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
  102. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  103. data/spec/unit/braintree/transaction_spec.rb +101 -93
  104. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  105. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  106. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  107. data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
  108. data/spec/unit/braintree/util_spec.rb +27 -27
  109. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  110. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  111. data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
  112. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  113. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  114. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  115. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  116. data/spec/unit/braintree/xml_spec.rb +17 -17
  117. data/spec/unit/braintree_spec.rb +2 -2
  118. metadata +7 -2
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::LocalPaymentDetails do
4
+ describe "initialize" do
5
+ let(:params) do
6
+ {
7
+ capture_id: "a-capture-id",
8
+ custom_field: "custom-field",
9
+ debug_id: "debug-id",
10
+ description: "description",
11
+ funding_source: "ideal",
12
+ implicitly_vaulted_payment_method_global_id: "global-id",
13
+ implicitly_vaulted_payment_method_token: "payment-method-token",
14
+ payer_id: "payer-id",
15
+ payment_id: "payment-id",
16
+ refund_from_transaction_fee_amount: "2.34",
17
+ refund_from_transaction_fee_currency_iso_code: "EUR",
18
+ refund_id: "a-refund-id",
19
+ transaction_fee_amount: "12.34",
20
+ transaction_fee_currency_iso_code: "EUR",
21
+ }
22
+ end
23
+
24
+ subject { described_class.new(params) }
25
+
26
+ it "sets all fields" do
27
+ is_expected.to have_attributes(**params)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,73 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::PaymentReceipt do
4
+ describe "inspect" do
5
+ it "assigns all fields" do
6
+ details = Braintree::Transaction::PaymentReceipt.new(
7
+ :account_balance => "2.00",
8
+ :amount => "10.00",
9
+ :card_last_4 => "1111",
10
+ :card_present_data => {
11
+ :application_cryptogram => "application-cryptogram",
12
+ :application_identifier => "application-id",
13
+ :application_interchange_profile => "application-interchange",
14
+ :application_name => "application-name",
15
+ :application_transaction_counter => "application-transaction-counter",
16
+ :application_usage_control => "application-usage-control",
17
+ :authorization_mode => "Issuer",
18
+ :authorization_response_code => "auth-response-code",
19
+ :card_entry_method => "card-entry-method",
20
+ :card_sequence_number => "card-sequence-number",
21
+ :cardholder_verification_method_results => "cardholder-verification-method-results",
22
+ :cashback_amount => "20.00",
23
+ :cryptogram_information_data => "cryptogram-information-data",
24
+ :issuer_action_code_default => "issuer-action-code-default",
25
+ :issuer_action_code_denial => "issuer-action-code-denial",
26
+ :issuer_action_code_online => "issuer-action-code-online",
27
+ :issuer_authentication_data => "issuer-authentication-data",
28
+ :terminal_country_code => "USA",
29
+ :terminal_transaction_date => "2023-04-03",
30
+ :terminal_transaction_type => "terminal-transaction-type",
31
+ :terminal_verification_result => "terminal-verification-result",
32
+ :unpredictable_number => "unpredictable-number",
33
+ },
34
+ :card_type => "VISA",
35
+ :currency_iso_code => "USD",
36
+ :global_id => "global-id",
37
+ :id => "id",
38
+ :merchant_address => {
39
+ :locality => "Chicago",
40
+ :phone => "7708675309",
41
+ :postal_code => "60652",
42
+ :region => "IL",
43
+ :street_address => "123 Sesame St",
44
+ },
45
+ :merchant_identification_number => "merchant-id-number",
46
+ :merchant_name => "merchant-name",
47
+ :pin_verified => true,
48
+ :processor_authorization_code => "processor-auth-code",
49
+ :processor_response_code => "processor-response-code",
50
+ :processor_response_text => "processor-response-text",
51
+ :terminal_identification_number => "terminal-id",
52
+ :type => "sale",
53
+ )
54
+
55
+ expect(details.account_balance).to eq("2.00")
56
+ expect(details.amount).to eq("10.00")
57
+ expect(details.card_last_4).to eq("1111")
58
+ expect(details.card_present_data).to eq({application_cryptogram: "application-cryptogram", application_identifier: "application-id", application_interchange_profile: "application-interchange", application_name: "application-name", application_transaction_counter: "application-transaction-counter", application_usage_control: "application-usage-control", authorization_mode: "Issuer", authorization_response_code: "auth-response-code", card_entry_method: "card-entry-method", card_sequence_number: "card-sequence-number", cardholder_verification_method_results: "cardholder-verification-method-results", cashback_amount: "20.00", cryptogram_information_data: "cryptogram-information-data", issuer_action_code_default: "issuer-action-code-default", issuer_action_code_denial: "issuer-action-code-denial", issuer_action_code_online: "issuer-action-code-online", issuer_authentication_data: "issuer-authentication-data", terminal_country_code: "USA", terminal_transaction_date: "2023-04-03", terminal_transaction_type: "terminal-transaction-type", terminal_verification_result: "terminal-verification-result", unpredictable_number: "unpredictable-number"})
59
+ expect(details.card_type).to eq("VISA")
60
+ expect(details.currency_iso_code).to eq("USD")
61
+ expect(details.global_id).to eq("global-id")
62
+ expect(details.id).to eq("id")
63
+ expect(details.merchant_address).to eq({locality: "Chicago", phone: "7708675309", postal_code: "60652", region: "IL", street_address: "123 Sesame St"})
64
+ expect(details.merchant_identification_number).to eq("merchant-id-number")
65
+ expect(details.merchant_name).to eq("merchant-name")
66
+ expect(details.pin_verified).to be_truthy
67
+ expect(details.processor_authorization_code).to be("processor-auth-code")
68
+ expect(details.processor_response_text).to be("processor-response-text")
69
+ expect(details.terminal_identification_number).to be("terminal-id")
70
+ expect(details.type).to be("sale")
71
+ end
72
+ end
73
+ end
@@ -14,9 +14,9 @@ describe Braintree::TransactionGateway do
14
14
  it "creates a transactionGateway gateway" do
15
15
  result = Braintree::TransactionGateway.new(gateway)
16
16
 
17
- result.inspect.should include("merchant_id")
18
- result.inspect.should include("public_key")
19
- result.inspect.should include("private_key")
17
+ expect(result.inspect).to include("merchant_id")
18
+ expect(result.inspect).to include("public_key")
19
+ expect(result.inspect).to include("private_key")
20
20
  end
21
21
 
22
22
  describe "self.create" do
@@ -28,6 +28,9 @@ describe Braintree::TransactionGateway do
28
28
  end
29
29
  end
30
30
 
31
+ # NEXT_MAJOR_VERSION Remove three_d_secure_token, venmo_sdk_payment_method_code, and venmo_sdk_session
32
+ # the old venmo SDK has been deprecated
33
+ # three_d_secure_token has been deprecated in favor of three_d_secure_authentication_id
31
34
  it "creates a transaction gateway signature" do
32
35
  expect(Braintree::TransactionGateway._create_signature).to match([
33
36
  :amount, :billing_address_id, :channel, :customer_id, :device_data, :discount_amount,
@@ -35,8 +38,8 @@ describe Braintree::TransactionGateway do
35
38
  :product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
36
39
  :shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
37
40
  :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,
41
+ :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
42
+ :transaction_source, :type, :venmo_sdk_payment_method_code, #Deprecated
40
43
  :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
41
44
  {: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
45
  {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
@@ -67,7 +70,7 @@ describe Braintree::TransactionGateway do
67
70
  :submit_for_settlement,
68
71
  :add_billing_address_to_payment_method,
69
72
  :store_shipping_address_in_vault,
70
- :venmo_sdk_session,
73
+ :venmo_sdk_session, #Deprecated
71
74
  :payee_id,
72
75
  :payee_email,
73
76
  :skip_advanced_fraud_checking,
@@ -5,14 +5,14 @@ describe Braintree::TransactionSearch do
5
5
  search = Braintree::TransactionSearch.new
6
6
  search.billing_company.is "one"
7
7
  search.billing_company.is "two"
8
- search.to_hash.should == {:billing_company => {:is => "two"}}
8
+ expect(search.to_hash).to eq({:billing_company => {:is => "two"}})
9
9
  end
10
10
 
11
11
  it "overrides previous 'in' with new 'in' for the same field" do
12
12
  search = Braintree::TransactionSearch.new
13
13
  search.status.in Braintree::Transaction::Status::Authorized
14
14
  search.status.in Braintree::Transaction::Status::SubmittedForSettlement
15
- search.to_hash.should == {:status => [Braintree::Transaction::Status::SubmittedForSettlement]}
15
+ expect(search.to_hash).to eq({:status => [Braintree::Transaction::Status::SubmittedForSettlement]})
16
16
  end
17
17
 
18
18
  it "raises if the operator 'is' is left off" do
@@ -76,14 +76,14 @@ describe Braintree::Transaction do
76
76
  :fax => "012-161-8055"
77
77
  },
78
78
  )
79
- transaction.customer_details.id.should == "123"
80
- transaction.customer_details.first_name.should == "Adam"
81
- transaction.customer_details.last_name.should == "Taylor"
82
- transaction.customer_details.company.should == "Ledner LLC"
83
- transaction.customer_details.email.should == "adam.taylor@lednerllc.com"
84
- transaction.customer_details.website.should == "lednerllc.com"
85
- transaction.customer_details.phone.should == "1-999-652-4189 x56883"
86
- transaction.customer_details.fax.should == "012-161-8055"
79
+ expect(transaction.customer_details.id).to eq("123")
80
+ expect(transaction.customer_details.first_name).to eq("Adam")
81
+ expect(transaction.customer_details.last_name).to eq("Taylor")
82
+ expect(transaction.customer_details.company).to eq("Ledner LLC")
83
+ expect(transaction.customer_details.email).to eq("adam.taylor@lednerllc.com")
84
+ expect(transaction.customer_details.website).to eq("lednerllc.com")
85
+ expect(transaction.customer_details.phone).to eq("1-999-652-4189 x56883")
86
+ expect(transaction.customer_details.fax).to eq("012-161-8055")
87
87
  end
88
88
 
89
89
  it "sets up disbursement attributes in disbursement_details" do
@@ -99,12 +99,12 @@ describe Braintree::Transaction do
99
99
  },
100
100
  )
101
101
  disbursement = transaction.disbursement_details
102
- disbursement.disbursement_date.should == Date.parse("2013-04-03")
103
- disbursement.settlement_amount.should == "120.00"
104
- disbursement.settlement_currency_iso_code.should == "USD"
105
- disbursement.settlement_currency_exchange_rate.should == "1"
106
- disbursement.funds_held?.should be(false)
107
- disbursement.success?.should be(true)
102
+ expect(disbursement.disbursement_date).to eq(Date.parse("2013-04-03"))
103
+ expect(disbursement.settlement_amount).to eq("120.00")
104
+ expect(disbursement.settlement_currency_iso_code).to eq("USD")
105
+ expect(disbursement.settlement_currency_exchange_rate).to eq("1")
106
+ expect(disbursement.funds_held?).to be(false)
107
+ expect(disbursement.success?).to be(true)
108
108
  end
109
109
 
110
110
  it "sets up credit card attributes in credit_card_details" do
@@ -129,22 +129,22 @@ describe Braintree::Transaction do
129
129
  :issuing_bank => "Mr Tumnus"
130
130
  },
131
131
  )
132
- transaction.credit_card_details.token.should == "mzg2"
133
- transaction.credit_card_details.bin.should == "411111"
134
- transaction.credit_card_details.last_4.should == "1111"
135
- transaction.credit_card_details.card_type.should == "Visa"
136
- transaction.credit_card_details.expiration_month.should == "08"
137
- transaction.credit_card_details.expiration_year.should == "2009"
138
- transaction.credit_card_details.customer_location.should == "US"
139
- transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
140
- transaction.credit_card_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
141
- transaction.credit_card_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
142
- transaction.credit_card_details.debit.should == Braintree::CreditCard::Debit::Yes
143
- transaction.credit_card_details.commercial.should == Braintree::CreditCard::Commercial::No
144
- transaction.credit_card_details.payroll.should == Braintree::CreditCard::Payroll::Unknown
145
- transaction.credit_card_details.product_id.should == Braintree::CreditCard::ProductId::Unknown
146
- transaction.credit_card_details.country_of_issuance.should == "Narnia"
147
- transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
132
+ expect(transaction.credit_card_details.token).to eq("mzg2")
133
+ expect(transaction.credit_card_details.bin).to eq("411111")
134
+ expect(transaction.credit_card_details.last_4).to eq("1111")
135
+ expect(transaction.credit_card_details.card_type).to eq("Visa")
136
+ expect(transaction.credit_card_details.expiration_month).to eq("08")
137
+ expect(transaction.credit_card_details.expiration_year).to eq("2009")
138
+ expect(transaction.credit_card_details.customer_location).to eq("US")
139
+ expect(transaction.credit_card_details.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
140
+ expect(transaction.credit_card_details.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
141
+ expect(transaction.credit_card_details.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
142
+ expect(transaction.credit_card_details.debit).to eq(Braintree::CreditCard::Debit::Yes)
143
+ expect(transaction.credit_card_details.commercial).to eq(Braintree::CreditCard::Commercial::No)
144
+ expect(transaction.credit_card_details.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
145
+ expect(transaction.credit_card_details.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
146
+ expect(transaction.credit_card_details.country_of_issuance).to eq("Narnia")
147
+ expect(transaction.credit_card_details.issuing_bank).to eq("Mr Tumnus")
148
148
  end
149
149
 
150
150
  it "sets up network token attributes in network_token_details" do
@@ -170,23 +170,23 @@ describe Braintree::Transaction do
170
170
  :is_network_tokenized => true
171
171
  },
172
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
173
+ expect(transaction.network_token_details.token).to eq("mzg2")
174
+ expect(transaction.network_token_details.bin).to eq("411111")
175
+ expect(transaction.network_token_details.last_4).to eq("1111")
176
+ expect(transaction.network_token_details.card_type).to eq("Visa")
177
+ expect(transaction.network_token_details.expiration_month).to eq("08")
178
+ expect(transaction.network_token_details.expiration_year).to eq("2009")
179
+ expect(transaction.network_token_details.customer_location).to eq("US")
180
+ expect(transaction.network_token_details.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
181
+ expect(transaction.network_token_details.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
182
+ expect(transaction.network_token_details.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
183
+ expect(transaction.network_token_details.debit).to eq(Braintree::CreditCard::Debit::Yes)
184
+ expect(transaction.network_token_details.commercial).to eq(Braintree::CreditCard::Commercial::No)
185
+ expect(transaction.network_token_details.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
186
+ expect(transaction.network_token_details.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
187
+ expect(transaction.network_token_details.country_of_issuance).to eq("Narnia")
188
+ expect(transaction.network_token_details.issuing_bank).to eq("Mr Tumnus")
189
+ expect(transaction.network_token_details.is_network_tokenized?).to eq(true)
190
190
  end
191
191
 
192
192
  it "sets up three_d_secure_info" do
@@ -200,10 +200,10 @@ describe Braintree::Transaction do
200
200
  },
201
201
  )
202
202
 
203
- transaction.three_d_secure_info.enrolled.should == "Y"
204
- transaction.three_d_secure_info.status.should == "authenticate_successful"
205
- transaction.three_d_secure_info.liability_shifted.should == true
206
- transaction.three_d_secure_info.liability_shift_possible.should == true
203
+ expect(transaction.three_d_secure_info.enrolled).to eq("Y")
204
+ expect(transaction.three_d_secure_info.status).to eq("authenticate_successful")
205
+ expect(transaction.three_d_secure_info.liability_shifted).to eq(true)
206
+ expect(transaction.three_d_secure_info.liability_shift_possible).to eq(true)
207
207
  end
208
208
 
209
209
  it "sets up history attributes in status_history" do
@@ -216,13 +216,13 @@ describe Braintree::Transaction do
216
216
  {:timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
217
217
  :user => "curly", :status => "scheduled_for_settlement"}
218
218
  ])
219
- transaction.status_history.size.should == 2
220
- transaction.status_history[0].user.should == "larry"
221
- transaction.status_history[0].amount.should == "12.00"
222
- transaction.status_history[0].status.should == Braintree::Transaction::Status::Authorized
223
- transaction.status_history[0].transaction_source.should == "API"
224
- transaction.status_history[0].timestamp.should == time
225
- transaction.status_history[1].user.should == "curly"
219
+ expect(transaction.status_history.size).to eq(2)
220
+ expect(transaction.status_history[0].user).to eq("larry")
221
+ expect(transaction.status_history[0].amount).to eq("12.00")
222
+ expect(transaction.status_history[0].status).to eq(Braintree::Transaction::Status::Authorized)
223
+ expect(transaction.status_history[0].transaction_source).to eq("API")
224
+ expect(transaction.status_history[0].timestamp).to eq(time)
225
+ expect(transaction.status_history[1].user).to eq("curly")
226
226
  end
227
227
 
228
228
  it "sets up authorization_adjustments" do
@@ -233,17 +233,17 @@ describe Braintree::Transaction do
233
233
  {:timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true},
234
234
  {:timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false},
235
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"
236
+ expect(transaction.authorization_adjustments.size).to eq(2)
237
+ expect(transaction.authorization_adjustments[0].amount).to eq("12.00")
238
+ expect(transaction.authorization_adjustments[0].success).to eq(true)
239
+ expect(transaction.authorization_adjustments[0].timestamp).to eq(timestamp)
240
+ expect(transaction.authorization_adjustments[0].processor_response_code).to eq("1000")
241
+ expect(transaction.authorization_adjustments[0].processor_response_text).to eq("Approved")
242
+ expect(transaction.authorization_adjustments[1].amount).to eq("12.34")
243
+ expect(transaction.authorization_adjustments[1].success).to eq(false)
244
+ expect(transaction.authorization_adjustments[1].timestamp).to eq(timestamp)
245
+ expect(transaction.authorization_adjustments[1].processor_response_code).to eq("3000")
246
+ expect(transaction.authorization_adjustments[1].processor_response_text).to eq("Processor Network Unavailable - Try Again")
247
247
  end
248
248
 
249
249
  it "accepts retry_ids and retried_transaction_id attributes in a transactions" do
@@ -252,9 +252,9 @@ describe Braintree::Transaction do
252
252
  :retry_ids => ["retry_id_1"],
253
253
  :retried_transaction_id => "original_retried_tranction_id",
254
254
  )
255
- transaction.retry_ids.count.should == 1
256
- transaction.retry_ids[0].should == "retry_id_1"
257
- transaction.retried_transaction_id.should == "original_retried_tranction_id"
255
+ expect(transaction.retry_ids.count).to eq(1)
256
+ expect(transaction.retry_ids[0]).to eq("retry_id_1")
257
+ expect(transaction.retried_transaction_id).to eq("original_retried_tranction_id")
258
258
  end
259
259
 
260
260
  it "handles receiving custom as an empty string" do
@@ -265,8 +265,8 @@ describe Braintree::Transaction do
265
265
  end
266
266
 
267
267
  it "accepts amount as either a String or a BigDecimal" do
268
- Braintree::Transaction._new(:gateway, :amount => "12.34").amount.should == BigDecimal("12.34")
269
- Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
268
+ expect(Braintree::Transaction._new(:gateway, :amount => "12.34").amount).to eq(BigDecimal("12.34"))
269
+ expect(Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount).to eq(BigDecimal("12.34"))
270
270
  end
271
271
 
272
272
  it "blows up if amount is not a string or BigDecimal" do
@@ -280,7 +280,7 @@ describe Braintree::Transaction do
280
280
  :gateway,
281
281
  :risk_data => nil,
282
282
  )
283
- transaction.risk_data.should be_nil
283
+ expect(transaction.risk_data).to be_nil
284
284
  end
285
285
 
286
286
  it "accepts network_transaction_id" do
@@ -288,7 +288,7 @@ describe Braintree::Transaction do
288
288
  :gateway,
289
289
  :network_transaction_id => "123456789012345",
290
290
  )
291
- transaction.network_transaction_id.should == "123456789012345"
291
+ expect(transaction.network_transaction_id).to eq("123456789012345")
292
292
  end
293
293
 
294
294
  it "accepts ach_return_code" do
@@ -339,7 +339,15 @@ describe Braintree::Transaction do
339
339
  },
340
340
  )
341
341
  details = transaction.sepa_direct_debit_account_details
342
- details.token.should == "1234"
342
+ expect(details.token).to eq("1234")
343
+ end
344
+
345
+ it "accepts debit_network" do
346
+ transaction = Braintree::Transaction._new(
347
+ :gateway,
348
+ :debit_network => "STAR",
349
+ )
350
+ expect(transaction.debit_network).to eq "STAR"
343
351
  end
344
352
  end
345
353
 
@@ -354,8 +362,8 @@ describe Braintree::Transaction do
354
362
  :processed_with_network_token => false,
355
363
  )
356
364
  output = transaction.inspect
357
- output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
358
- output.should include(%Q(processed_with_network_token?: false))
365
+ expect(output).to include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
366
+ expect(output).to include(%Q(processed_with_network_token?: false))
359
367
  end
360
368
  end
361
369
 
@@ -364,27 +372,27 @@ describe Braintree::Transaction do
364
372
  first = Braintree::Transaction._new(:gateway, :id => 123)
365
373
  second = Braintree::Transaction._new(:gateway, :id => 123)
366
374
 
367
- first.should == second
368
- second.should == first
375
+ expect(first).to eq(second)
376
+ expect(second).to eq(first)
369
377
  end
370
378
 
371
379
  it "returns false for transactions with different ids" do
372
380
  first = Braintree::Transaction._new(:gateway, :id => 123)
373
381
  second = Braintree::Transaction._new(:gateway, :id => 124)
374
382
 
375
- first.should_not == second
376
- second.should_not == first
383
+ expect(first).not_to eq(second)
384
+ expect(second).not_to eq(first)
377
385
  end
378
386
 
379
387
  it "returns false when comparing to nil" do
380
- Braintree::Transaction._new(:gateway, {}).should_not == nil
388
+ expect(Braintree::Transaction._new(:gateway, {})).not_to eq(nil)
381
389
  end
382
390
 
383
391
  it "returns false when comparing to non-transactions" do
384
392
  same_id_different_object = Object.new
385
393
  def same_id_different_object.id; 123; end
386
394
  transaction = Braintree::Transaction._new(:gateway, :id => 123)
387
- transaction.should_not == same_id_different_object
395
+ expect(transaction).not_to eq(same_id_different_object)
388
396
  end
389
397
  end
390
398
 
@@ -399,12 +407,12 @@ describe Braintree::Transaction do
399
407
  describe "refunded?" do
400
408
  it "is true if the transaciton has been refunded" do
401
409
  transaction = Braintree::Transaction._new(:gateway, :refund_id => "123")
402
- transaction.refunded?.should == true
410
+ expect(transaction.refunded?).to eq(true)
403
411
  end
404
412
 
405
413
  it "is false if the transaciton has not been refunded" do
406
414
  transaction = Braintree::Transaction._new(:gateway, :refund_id => nil)
407
- transaction.refunded?.should == false
415
+ expect(transaction.refunded?).to eq(false)
408
416
  end
409
417
  end
410
418
 
@@ -417,7 +425,7 @@ describe Braintree::Transaction do
417
425
  end
418
426
 
419
427
  it "accepts skip_advanced_fraud_checking options with value true" do
420
- Braintree::Http.stub(:new).and_return http_stub
428
+ allow(Braintree::Http).to receive(:new).and_return http_stub
421
429
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(true)).and_return(mock_response)
422
430
 
423
431
  Braintree::Transaction.sale(
@@ -433,7 +441,7 @@ describe Braintree::Transaction do
433
441
  end
434
442
 
435
443
  it "accepts skip_advanced_fraud_checking options with value false" do
436
- Braintree::Http.stub(:new).and_return http_stub
444
+ allow(Braintree::Http).to receive(:new).and_return http_stub
437
445
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(false)).and_return(mock_response)
438
446
 
439
447
  Braintree::Transaction.sale(
@@ -449,7 +457,7 @@ describe Braintree::Transaction do
449
457
  end
450
458
 
451
459
  it "doesn't include skip_advanced_fraud_checking in params if its not specified" do
452
- Braintree::Http.stub(:new).and_return http_stub
460
+ allow(Braintree::Http).to receive(:new).and_return http_stub
453
461
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(nil)).and_return(mock_response)
454
462
 
455
463
  Braintree::Transaction.sale(
@@ -468,19 +476,19 @@ describe Braintree::Transaction do
468
476
  describe "processed_with_network_token?" do
469
477
  it "is true if the transaction was processed with a network token" do
470
478
  transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => true)
471
- transaction.processed_with_network_token?.should == true
479
+ expect(transaction.processed_with_network_token?).to eq(true)
472
480
  end
473
481
 
474
482
  it "is false if the transaction was not processed with a network token" do
475
483
  transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => false)
476
- transaction.processed_with_network_token?.should == false
484
+ expect(transaction.processed_with_network_token?).to eq(false)
477
485
  end
478
486
  end
479
487
 
480
488
  describe "gateway rejection reason" do
481
489
  it "verifies excessive_retry mapping" do
482
490
  transaction = Braintree::Transaction._new(:gateway, :gateway_rejection_reason => "excessive_retry")
483
- transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry
491
+ expect(transaction.gateway_rejection_reason).to eq(Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry)
484
492
  end
485
493
  end
486
494
  end
@@ -8,26 +8,26 @@ describe Braintree::PayPalAccount do
8
8
  describe "token" do
9
9
  it "has a token identifier" do
10
10
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
11
- Braintree::UnknownPaymentMethod.new(@gateway, params).token.should == 1234
11
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params).token).to eq(1234)
12
12
  end
13
13
  end
14
14
 
15
15
  describe "image_url" do
16
16
  it "has a image_url" do
17
17
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
18
- Braintree::UnknownPaymentMethod.new(@gateway, params).image_url.should == "https://assets.braintreegateway.com/payment_method_logo/unknown.png"
18
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params).image_url).to eq("https://assets.braintreegateway.com/payment_method_logo/unknown.png")
19
19
  end
20
20
  end
21
21
 
22
22
  describe "default?" do
23
23
  it "is true if the paypal account is the default payment method for the customer" do
24
24
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
25
- Braintree::UnknownPaymentMethod.new(@gateway, params).should be_default
25
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params)).to be_default
26
26
  end
27
27
 
28
28
  it "is false if the paypal account is not the default payment methodfor the customer" do
29
29
  params = {:unknown_payment_method => {:token => 1234, :default => false}}
30
- Braintree::UnknownPaymentMethod.new(@gateway, params).should_not be_default
30
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params)).not_to be_default
31
31
  end
32
32
  end
33
33
  end
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::UsBankAccount do
4
4
  describe "default?" do
5
5
  it "is true if the us bank account is the default us bank account for the customer" do
6
- Braintree::UsBankAccount._new(:gateway, :default => true).default?.should == true
6
+ expect(Braintree::UsBankAccount._new(:gateway, :default => true).default?).to eq(true)
7
7
  end
8
8
 
9
9
  it "is false if the us bank account is not the default us bank account for the customer" do
10
- Braintree::UsBankAccount._new(:gateway, :default => false).default?.should == false
10
+ expect(Braintree::UsBankAccount._new(:gateway, :default => false).default?).to eq(false)
11
11
  end
12
12
  end
13
13
  end
@@ -6,11 +6,11 @@ module Braintree
6
6
  it "allows All verification methods" do
7
7
  search = UsBankAccountVerificationSearch.new
8
8
 
9
- lambda do
9
+ expect do
10
10
  search.verification_method.in(
11
11
  *Braintree::UsBankAccountVerification::VerificationMethod::All,
12
12
  )
13
- end.should_not raise_error
13
+ end.not_to raise_error
14
14
  end
15
15
  end
16
16
 
@@ -19,7 +19,7 @@ module Braintree
19
19
  search = UsBankAccountVerificationSearch.new
20
20
  search.id.is "v_id"
21
21
 
22
- search.to_hash.should == {:id => {:is => "v_id"}}
22
+ expect(search.to_hash).to eq({:id => {:is => "v_id"}})
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ module Braintree
28
28
  search = UsBankAccountVerificationSearch.new
29
29
  search.ids.in("id1", "id2")
30
30
 
31
- search.to_hash.should == {:ids => ["id1", "id2"]}
31
+ expect(search.to_hash).to eq({:ids => ["id1", "id2"]})
32
32
  end
33
33
  end
34
34
 
@@ -37,14 +37,14 @@ module Braintree
37
37
  search = UsBankAccountVerificationSearch.new
38
38
  search.account_holder_name.is "v_account_holder_name"
39
39
 
40
- search.to_hash.should == {:account_holder_name => {:is => "v_account_holder_name"}}
40
+ expect(search.to_hash).to eq({:account_holder_name => {:is => "v_account_holder_name"}})
41
41
  end
42
42
  end
43
43
 
44
44
  context "created_at" do
45
45
  it "is a range node" do
46
46
  search = UsBankAccountVerificationSearch.new
47
- search.created_at.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
47
+ expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ module Braintree
53
53
  search = UsBankAccountVerificationSearch.new
54
54
  search.account_number.ends_with "1234"
55
55
 
56
- search.to_hash.should == {:account_number => {:ends_with => "1234"}}
56
+ expect(search.to_hash).to eq({:account_number => {:ends_with => "1234"}})
57
57
  end
58
58
  end
59
59
  end