braintree 4.14.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +3 -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
|
|
@@ -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.
|
|
18
|
-
result.inspect.
|
|
19
|
-
result.inspect.
|
|
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
|
-
:
|
|
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.
|
|
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.
|
|
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.
|
|
80
|
-
transaction.customer_details.first_name.
|
|
81
|
-
transaction.customer_details.last_name.
|
|
82
|
-
transaction.customer_details.company.
|
|
83
|
-
transaction.customer_details.email.
|
|
84
|
-
transaction.customer_details.website.
|
|
85
|
-
transaction.customer_details.phone.
|
|
86
|
-
transaction.customer_details.fax.
|
|
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.
|
|
103
|
-
disbursement.settlement_amount.
|
|
104
|
-
disbursement.settlement_currency_iso_code.
|
|
105
|
-
disbursement.settlement_currency_exchange_rate.
|
|
106
|
-
disbursement.funds_held
|
|
107
|
-
disbursement.success
|
|
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.
|
|
133
|
-
transaction.credit_card_details.bin.
|
|
134
|
-
transaction.credit_card_details.last_4.
|
|
135
|
-
transaction.credit_card_details.card_type.
|
|
136
|
-
transaction.credit_card_details.expiration_month.
|
|
137
|
-
transaction.credit_card_details.expiration_year.
|
|
138
|
-
transaction.credit_card_details.customer_location.
|
|
139
|
-
transaction.credit_card_details.prepaid.
|
|
140
|
-
transaction.credit_card_details.healthcare.
|
|
141
|
-
transaction.credit_card_details.durbin_regulated.
|
|
142
|
-
transaction.credit_card_details.debit.
|
|
143
|
-
transaction.credit_card_details.commercial.
|
|
144
|
-
transaction.credit_card_details.payroll.
|
|
145
|
-
transaction.credit_card_details.product_id.
|
|
146
|
-
transaction.credit_card_details.country_of_issuance.
|
|
147
|
-
transaction.credit_card_details.issuing_bank.
|
|
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.
|
|
174
|
-
transaction.network_token_details.bin.
|
|
175
|
-
transaction.network_token_details.last_4.
|
|
176
|
-
transaction.network_token_details.card_type.
|
|
177
|
-
transaction.network_token_details.expiration_month.
|
|
178
|
-
transaction.network_token_details.expiration_year.
|
|
179
|
-
transaction.network_token_details.customer_location.
|
|
180
|
-
transaction.network_token_details.prepaid.
|
|
181
|
-
transaction.network_token_details.healthcare.
|
|
182
|
-
transaction.network_token_details.durbin_regulated.
|
|
183
|
-
transaction.network_token_details.debit.
|
|
184
|
-
transaction.network_token_details.commercial.
|
|
185
|
-
transaction.network_token_details.payroll.
|
|
186
|
-
transaction.network_token_details.product_id.
|
|
187
|
-
transaction.network_token_details.country_of_issuance.
|
|
188
|
-
transaction.network_token_details.issuing_bank.
|
|
189
|
-
transaction.network_token_details.is_network_tokenized
|
|
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.
|
|
204
|
-
transaction.three_d_secure_info.status.
|
|
205
|
-
transaction.three_d_secure_info.liability_shifted.
|
|
206
|
-
transaction.three_d_secure_info.liability_shift_possible.
|
|
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.
|
|
220
|
-
transaction.status_history[0].user.
|
|
221
|
-
transaction.status_history[0].amount.
|
|
222
|
-
transaction.status_history[0].status.
|
|
223
|
-
transaction.status_history[0].transaction_source.
|
|
224
|
-
transaction.status_history[0].timestamp.
|
|
225
|
-
transaction.status_history[1].user.
|
|
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.
|
|
237
|
-
transaction.authorization_adjustments[0].amount.
|
|
238
|
-
transaction.authorization_adjustments[0].success.
|
|
239
|
-
transaction.authorization_adjustments[0].timestamp.
|
|
240
|
-
transaction.authorization_adjustments[0].processor_response_code.
|
|
241
|
-
transaction.authorization_adjustments[0].processor_response_text.
|
|
242
|
-
transaction.authorization_adjustments[1].amount.
|
|
243
|
-
transaction.authorization_adjustments[1].success.
|
|
244
|
-
transaction.authorization_adjustments[1].timestamp.
|
|
245
|
-
transaction.authorization_adjustments[1].processor_response_code.
|
|
246
|
-
transaction.authorization_adjustments[1].processor_response_text.
|
|
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.
|
|
256
|
-
transaction.retry_ids[0].
|
|
257
|
-
transaction.retried_transaction_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.
|
|
269
|
-
Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
358
|
-
output.
|
|
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.
|
|
368
|
-
second.
|
|
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.
|
|
376
|
-
second.
|
|
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, {}).
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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).
|
|
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).
|
|
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
|
|
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
|
|
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
|
-
|
|
9
|
+
expect do
|
|
10
10
|
search.verification_method.in(
|
|
11
11
|
*Braintree::UsBankAccountVerification::VerificationMethod::All,
|
|
12
12
|
)
|
|
13
|
-
end.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
56
|
+
expect(search.to_hash).to eq({:account_number => {:ends_with => "1234"}})
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -12,7 +12,7 @@ describe Braintree::UsBankAccountVerification do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "has a status" do
|
|
15
|
-
verification.status.
|
|
15
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -67,27 +67,27 @@ describe Braintree::UsBankAccountVerification do
|
|
|
67
67
|
first = Braintree::UsBankAccountVerification._new(:id => "123")
|
|
68
68
|
second = Braintree::UsBankAccountVerification._new(:id => "123")
|
|
69
69
|
|
|
70
|
-
first.
|
|
71
|
-
second.
|
|
70
|
+
expect(first).to eq(second)
|
|
71
|
+
expect(second).to eq(first)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "returns false for verifications with different ids" do
|
|
75
75
|
first = Braintree::UsBankAccountVerification._new(:id => "123")
|
|
76
76
|
second = Braintree::UsBankAccountVerification._new(:id => "124")
|
|
77
77
|
|
|
78
|
-
first.
|
|
79
|
-
second.
|
|
78
|
+
expect(first).not_to eq(second)
|
|
79
|
+
expect(second).not_to eq(first)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "returns false when comparing to nil" do
|
|
83
|
-
Braintree::UsBankAccountVerification._new({}).
|
|
83
|
+
expect(Braintree::UsBankAccountVerification._new({})).not_to eq(nil)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it "returns false when comparing to non-verifications" do
|
|
87
87
|
same_id_different_object = Object.new
|
|
88
88
|
def same_id_different_object.id; "123"; end
|
|
89
89
|
verification = Braintree::UsBankAccountVerification._new(:id => "123")
|
|
90
|
-
verification.
|
|
90
|
+
expect(verification).not_to eq(same_id_different_object)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|