braintree 2.74.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/braintree.gemspec +13 -7
- data/lib/braintree/account_updater_daily_report.rb +2 -2
- data/lib/braintree/ach_mandate.rb +2 -1
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +30 -38
- data/lib/braintree/address_gateway.rb +12 -2
- data/lib/braintree/advanced_search.rb +8 -0
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +28 -4
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +10 -0
- data/lib/braintree/bin_data.rb +33 -0
- data/lib/braintree/client_token.rb +3 -3
- data/lib/braintree/client_token_gateway.rb +3 -1
- data/lib/braintree/configuration.rb +57 -10
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
- data/lib/braintree/credentials_parser.rb +5 -1
- data/lib/braintree/credit_card.rb +53 -107
- data/lib/braintree/credit_card_gateway.rb +43 -30
- data/lib/braintree/credit_card_verification.rb +61 -21
- data/lib/braintree/credit_card_verification_gateway.rb +19 -6
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +51 -98
- data/lib/braintree/customer_gateway.rb +30 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +3 -1
- data/lib/braintree/disbursement.rb +24 -2
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +2 -1
- data/lib/braintree/dispute.rb +114 -10
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +328 -109
- data/lib/braintree/error_result.rb +8 -1
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +21 -0
- data/lib/braintree/facilitator_details.rb +2 -1
- data/lib/braintree/gateway.rb +29 -11
- data/lib/braintree/google_pay_card.rb +61 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql_client.rb +34 -0
- data/lib/braintree/http.rb +81 -20
- data/lib/braintree/local_payment_completed.rb +23 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +11 -4
- data/lib/braintree/merchant_account/address_details.rb +4 -1
- data/lib/braintree/merchant_account/business_details.rb +4 -1
- data/lib/braintree/merchant_account/funding_details.rb +6 -1
- data/lib/braintree/merchant_account/individual_details.rb +7 -2
- data/lib/braintree/merchant_account.rb +23 -10
- data/lib/braintree/merchant_account_gateway.rb +13 -1
- data/lib/braintree/merchant_gateway.rb +2 -2
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +5 -2
- data/lib/braintree/oauth_gateway.rb +8 -14
- data/lib/braintree/paginated_result.rb +3 -1
- data/lib/braintree/payment_instrument_type.rb +11 -11
- data/lib/braintree/payment_method.rb +20 -12
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +82 -54
- data/lib/braintree/payment_method_nonce.rb +22 -8
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
- data/lib/braintree/payment_method_parser.rb +28 -0
- data/lib/braintree/paypal_account.rb +10 -1
- data/lib/braintree/plan.rb +25 -5
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +12 -2
- data/lib/braintree/samsung_pay_card.rb +83 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
- data/lib/braintree/subscription/status_details.rb +8 -1
- data/lib/braintree/subscription.rb +56 -41
- data/lib/braintree/subscription_gateway.rb +25 -2
- data/lib/braintree/successful_result.rb +23 -1
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +13 -0
- data/lib/braintree/test/nonce.rb +28 -20
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +34 -2
- data/lib/braintree/transaction/address_details.rb +24 -4
- data/lib/braintree/transaction/apple_pay_details.rb +20 -2
- data/lib/braintree/transaction/credit_card_details.rb +45 -6
- data/lib/braintree/transaction/customer_details.rb +8 -1
- data/lib/braintree/transaction/disbursement_details.rb +6 -1
- data/lib/braintree/transaction/google_pay_details.rb +41 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +24 -0
- data/lib/braintree/transaction/paypal_details.rb +26 -4
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +5 -1
- data/lib/braintree/transaction/subscription_details.rb +4 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
- data/lib/braintree/transaction/venmo_account_details.rb +5 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
- data/lib/braintree/transaction.rb +201 -188
- data/lib/braintree/transaction_gateway.rb +124 -30
- data/lib/braintree/transaction_line_item.rb +40 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +6 -3
- data/lib/braintree/unknown_payment_method.rb +3 -2
- data/lib/braintree/us_bank_account.rb +24 -8
- data/lib/braintree/us_bank_account_gateway.rb +0 -1
- data/lib/braintree/us_bank_account_verification.rb +81 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +79 -9
- data/lib/braintree/validation_error.rb +13 -3
- data/lib/braintree/validation_error_collection.rb +2 -1
- data/lib/braintree/venmo_account.rb +11 -4
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +29 -13
- data/lib/braintree/webhook_notification.rb +66 -26
- data/lib/braintree/webhook_notification_gateway.rb +5 -3
- data/lib/braintree/webhook_testing.rb +2 -2
- data/lib/braintree/webhook_testing_gateway.rb +721 -55
- data/lib/braintree/xml/generator.rb +6 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +60 -22
- data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +3 -3
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
- data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
- data/spec/integration/braintree/credit_card_spec.rb +460 -615
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +810 -498
- data/spec/integration/braintree/discount_spec.rb +1 -1
- data/spec/integration/braintree/dispute_search_spec.rb +167 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +12 -4
- data/spec/integration/braintree/merchant_account_spec.rb +74 -26
- data/spec/integration/braintree/merchant_spec.rb +39 -13
- data/spec/integration/braintree/oauth_spec.rb +18 -25
- data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
- data/spec/integration/braintree/payment_method_spec.rb +882 -300
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
- data/spec/integration/braintree/paypal_account_spec.rb +32 -31
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +274 -180
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +18 -18
- data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
- data/spec/integration/braintree/transaction_search_spec.rb +280 -152
- data/spec/integration/braintree/transaction_spec.rb +3709 -1175
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +27 -6
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +26 -23
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +108 -33
- data/spec/unit/braintree/credit_card_spec.rb +62 -33
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
- data/spec/unit/braintree/customer_spec.rb +107 -27
- data/spec/unit/braintree/disbursement_spec.rb +59 -7
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +472 -8
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +93 -5
- data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +40 -6
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/subscription_spec.rb +2 -2
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
- 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/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +171 -55
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
- data/spec/unit/braintree/util_spec.rb +162 -19
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -24
- data/spec/unit/braintree_spec.rb +1 -0
- metadata +290 -198
- data/README.rdoc +0 -93
- data/lib/braintree/amex_express_checkout_card.rb +0 -26
- data/lib/braintree/android_pay_card.rb +0 -35
- data/lib/braintree/coinbase_account.rb +0 -25
- data/lib/braintree/europe_bank_account.rb +0 -34
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -46
- data/lib/braintree/ideal_payment_gateway.rb +0 -18
- data/lib/braintree/masterpass_card.rb +0 -66
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
- data/lib/braintree/transaction/android_pay_details.rb +0 -17
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/httpsd.pid +0 -1
- data/spec/integration/braintree/coinbase_spec.rb +0 -31
- data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -4,7 +4,7 @@ describe Braintree::Errors do
|
|
4
4
|
describe "for" do
|
5
5
|
it "accesses errors for the given scope" do
|
6
6
|
errors = Braintree::Errors.new(
|
7
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
7
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
8
8
|
)
|
9
9
|
errors.for(:level1).size.should == 1
|
10
10
|
errors.for(:level1)[0].code.should == "code1"
|
@@ -12,7 +12,7 @@ describe Braintree::Errors do
|
|
12
12
|
|
13
13
|
it "returns nil if there are no errors at the given scope" do
|
14
14
|
errors = Braintree::Errors.new(
|
15
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
15
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
16
16
|
)
|
17
17
|
errors.for(:no_errors_here).should == nil
|
18
18
|
end
|
@@ -21,7 +21,7 @@ describe Braintree::Errors do
|
|
21
21
|
describe "inspect" do
|
22
22
|
it "is better than the default inspect" do
|
23
23
|
errors = Braintree::Errors.new(
|
24
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
24
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
25
25
|
)
|
26
26
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
|
27
27
|
end
|
@@ -33,7 +33,7 @@ describe Braintree::Errors do
|
|
33
33
|
:level2 => {
|
34
34
|
:errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}],
|
35
35
|
}
|
36
|
-
}
|
36
|
+
},
|
37
37
|
)
|
38
38
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
|
39
39
|
end
|
@@ -48,7 +48,7 @@ describe Braintree::Errors do
|
|
48
48
|
:errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}],
|
49
49
|
}
|
50
50
|
}
|
51
|
-
}
|
51
|
+
},
|
52
52
|
)
|
53
53
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
|
54
54
|
end
|
@@ -65,7 +65,7 @@ describe Braintree::Errors do
|
|
65
65
|
{:code => "3", :attribute => "attr3", :message => "message3"}
|
66
66
|
],
|
67
67
|
}
|
68
|
-
}
|
68
|
+
},
|
69
69
|
)
|
70
70
|
errors.map { |e| e.code }.sort.should == %w[1 2 3]
|
71
71
|
end
|
@@ -74,7 +74,7 @@ describe Braintree::Errors do
|
|
74
74
|
describe "size" do
|
75
75
|
it "returns the number of validation errors at the first level if only has one level" do
|
76
76
|
errors = Braintree::Errors.new(
|
77
|
-
:level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}
|
77
|
+
:level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
|
78
78
|
)
|
79
79
|
errors.size.should == 1
|
80
80
|
end
|
@@ -89,7 +89,7 @@ describe Braintree::Errors do
|
|
89
89
|
{:code => "3", :attribute => "attr3", :message => "message3"}
|
90
90
|
],
|
91
91
|
}
|
92
|
-
}
|
92
|
+
},
|
93
93
|
)
|
94
94
|
errors.size.should == 3
|
95
95
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::ExchangeRateQuoteInput do
|
4
|
+
let(:exchange_rate_quote_input) do
|
5
|
+
{
|
6
|
+
base_currency: "USD",
|
7
|
+
quote_currency: "EUR",
|
8
|
+
base_amount: "10.00",
|
9
|
+
markup: "2.00"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "initialize and sets the input keys to attrs variable" do
|
15
|
+
quote_input = described_class.new(exchange_rate_quote_input)
|
16
|
+
|
17
|
+
expect(quote_input.attrs).to include(:base_currency)
|
18
|
+
expect(quote_input.attrs).to include(:quote_currency)
|
19
|
+
expect(quote_input.attrs).to include(:base_amount)
|
20
|
+
expect(quote_input.attrs).to include(:markup)
|
21
|
+
expect(quote_input.attrs.length).to eq(4)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "inspect" do
|
26
|
+
it "includes the base_currency first" do
|
27
|
+
output = described_class.new(base_currency: "USD").inspect
|
28
|
+
|
29
|
+
expect(output).to include("#<Braintree::ExchangeRateQuoteInput base_currency:\"USD\">")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "includes all quote input attributes" do
|
33
|
+
quote_input = described_class.new(exchange_rate_quote_input)
|
34
|
+
output = quote_input.inspect
|
35
|
+
|
36
|
+
expect(output).to include("base_currency:\"USD\"")
|
37
|
+
expect(output).to include("quote_currency:\"EUR\"")
|
38
|
+
expect(output).to include("base_amount:\"10.00\"")
|
39
|
+
expect(output).to include("markup:\"2.00\"")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::ExchangeRateQuoteRequest do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "creates and validates the exchange rate quote request" do
|
6
|
+
req = Braintree::ExchangeRateQuoteRequest.new(
|
7
|
+
:quotes => [
|
8
|
+
{
|
9
|
+
:base_currency => "USD",
|
10
|
+
:quote_currency => "EUR",
|
11
|
+
:base_amount => "10.00",
|
12
|
+
:markup => "2.00"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
:base_currency => "EUR",
|
16
|
+
:quote_currency => "GBP",
|
17
|
+
:base_amount => "20.00",
|
18
|
+
:markup => "4.00"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
)
|
22
|
+
|
23
|
+
expect(req.quotes[0].base_currency).to eq("USD")
|
24
|
+
expect(req.quotes[0].quote_currency).to eq("EUR")
|
25
|
+
expect(req.quotes[0].base_amount).to eq("10.00")
|
26
|
+
expect(req.quotes[0].markup).to eq("2.00")
|
27
|
+
|
28
|
+
expect(req.quotes[1].base_currency).to eq("EUR")
|
29
|
+
expect(req.quotes[1].quote_currency).to eq("GBP")
|
30
|
+
expect(req.quotes[1].base_amount).to eq("20.00")
|
31
|
+
expect(req.quotes[1].markup).to eq("4.00")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "creates and validates the exchange rate quote request without amount and markup" do
|
35
|
+
req = Braintree::ExchangeRateQuoteRequest.new(
|
36
|
+
:quotes => [
|
37
|
+
{
|
38
|
+
:base_currency => "USD",
|
39
|
+
:quote_currency => "EUR",
|
40
|
+
},
|
41
|
+
{
|
42
|
+
:base_currency => "EUR",
|
43
|
+
:quote_currency => "GBP",
|
44
|
+
}
|
45
|
+
],
|
46
|
+
)
|
47
|
+
|
48
|
+
expect(req.quotes[0].base_currency).to eq("USD")
|
49
|
+
expect(req.quotes[0].quote_currency).to eq("EUR")
|
50
|
+
expect(req.quotes[0].base_amount).to be_nil
|
51
|
+
expect(req.quotes[0].markup).to be_nil
|
52
|
+
|
53
|
+
expect(req.quotes[1].base_currency).to eq("EUR")
|
54
|
+
expect(req.quotes[1].quote_currency).to eq("GBP")
|
55
|
+
expect(req.quotes[1].base_amount).to be_nil
|
56
|
+
expect(req.quotes[1].markup).to be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "inspect" do
|
62
|
+
it "prints the attributes" do
|
63
|
+
exchange_rate_req = Braintree::ExchangeRateQuoteRequest.new(
|
64
|
+
:quotes => [
|
65
|
+
{
|
66
|
+
:base_currency => "USD",
|
67
|
+
:quote_currency => "EUR",
|
68
|
+
:base_amount => "10.00",
|
69
|
+
:markup => "2.00"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
:base_currency => "EUR",
|
73
|
+
:quote_currency => "GBP",
|
74
|
+
:base_amount => "20.00",
|
75
|
+
:markup => "4.00"
|
76
|
+
}
|
77
|
+
],
|
78
|
+
)
|
79
|
+
expect(exchange_rate_req.inspect).to eq(%(#<Braintree::ExchangeRateQuoteRequest quotes:[#<Braintree::ExchangeRateQuoteInput base_currency:"USD" quote_currency:"EUR" base_amount:"10.00" markup:"2.00">, #<Braintree::ExchangeRateQuoteInput base_currency:"EUR" quote_currency:"GBP" base_amount:"20.00" markup:"4.00">]>))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::ExchangeRateQuoteResponse do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "creates and validated the exchange rate quote payload" do
|
6
|
+
quote_payload = Braintree::ExchangeRateQuoteResponse.new(
|
7
|
+
quotes: [
|
8
|
+
{
|
9
|
+
:base_amount => "10.00",
|
10
|
+
:quote_amount => "9.03",
|
11
|
+
:exchange_rate => "0.90"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
:base_amount => "20.00",
|
15
|
+
:quote_amount => "18.06",
|
16
|
+
:exchange_rate => "0.90"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
)
|
20
|
+
|
21
|
+
quote_1 = quote_payload.quotes[0]
|
22
|
+
quote_2 = quote_payload.quotes[1]
|
23
|
+
|
24
|
+
expect(quote_1.base_amount).to eq("10.00")
|
25
|
+
expect(quote_1.quote_amount).to eq("9.03")
|
26
|
+
expect(quote_1.exchange_rate).to eq("0.90")
|
27
|
+
|
28
|
+
expect(quote_2.base_amount).to eq("20.00")
|
29
|
+
expect(quote_2.quote_amount).to eq("18.06")
|
30
|
+
expect(quote_1.exchange_rate).to eq("0.90")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "inspect" do
|
35
|
+
it "prints the attributes" do
|
36
|
+
exchange_rate_quote_payload = Braintree::ExchangeRateQuoteResponse.new(
|
37
|
+
quotes: [
|
38
|
+
{
|
39
|
+
:base_amount => "10.00",
|
40
|
+
:quote_amount => "9.03"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
:base_amount => "20.00",
|
44
|
+
:quote_amount => "18.06"
|
45
|
+
}
|
46
|
+
],
|
47
|
+
)
|
48
|
+
|
49
|
+
expect(exchange_rate_quote_payload.inspect).to eq(%(#<Braintree::ExchangeRateQuoteResponse quotes:[#<Braintree::ExchangeRateQuote base_amount:"10.00" quote_amount:"9.03">, #<Braintree::ExchangeRateQuote base_amount:"20.00" quote_amount:"18.06">]>))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::ExchangeRateQuote do
|
4
|
+
let(:rate_quote) do
|
5
|
+
{
|
6
|
+
id: "1234",
|
7
|
+
base_amount: "10.00",
|
8
|
+
exchange_rate: "74",
|
9
|
+
quote_amount: "740"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "initialize and sets the input keys to attrs variable" do
|
15
|
+
quote = described_class.new(rate_quote)
|
16
|
+
|
17
|
+
expect(quote.attrs).to include(:id)
|
18
|
+
expect(quote.attrs).to include(:base_amount)
|
19
|
+
expect(quote.attrs).to include(:exchange_rate)
|
20
|
+
expect(quote.attrs).to include(:quote_amount)
|
21
|
+
expect(quote.attrs.length).to eq(4)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "inspect" do
|
26
|
+
it "includes the id first" do
|
27
|
+
output = described_class.new(id: "1234").inspect
|
28
|
+
|
29
|
+
expect(output).to include("#<Braintree::ExchangeRateQuote id:\"1234\">")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "includes all quote attributes" do
|
33
|
+
quote = described_class.new(rate_quote)
|
34
|
+
output = quote.inspect
|
35
|
+
|
36
|
+
expect(output).to include("id:\"1234\"")
|
37
|
+
expect(output).to include("base_amount:\"10.00\"")
|
38
|
+
expect(output).to include("exchange_rate:\"74\"")
|
39
|
+
expect(output).to include("quote_amount:\"740\"")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe ::Braintree::ExchangeRate do
|
4
|
+
let(:rate_quote) do
|
5
|
+
{
|
6
|
+
id: "1234",
|
7
|
+
base_amount: "10.00",
|
8
|
+
exchange_rate: "74",
|
9
|
+
quote_amount: "740"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "initialize and sets the attributes" do
|
15
|
+
exchange_rate = described_class.new(:gateway, rate_quote).inspect
|
16
|
+
|
17
|
+
expect(exchange_rate).to include("@id=\"1234\"")
|
18
|
+
expect(exchange_rate).to include("@base_amount=\"10.00\"")
|
19
|
+
expect(exchange_rate).to include("@exchange_rate=\"74\"")
|
20
|
+
expect(exchange_rate).to include("@quote_amount=\"740\"")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -25,6 +25,7 @@ END
|
|
25
25
|
<last-name>Doe</last-name>
|
26
26
|
<number>1234560000001234</number>
|
27
27
|
<cvv>123</cvv>
|
28
|
+
<encrypted-card-data>8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881</encrypted-card-data>
|
28
29
|
</customer>
|
29
30
|
END
|
30
31
|
|
@@ -34,17 +35,41 @@ END
|
|
34
35
|
[Braintree] <last-name>Doe</last-name>
|
35
36
|
[Braintree] <number>123456******1234</number>
|
36
37
|
[Braintree] <cvv>***</cvv>
|
38
|
+
[Braintree] <encrypted-card-data>***</encrypted-card-data>
|
37
39
|
[Braintree] </customer>
|
38
40
|
END
|
39
41
|
Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
|
40
42
|
end
|
41
43
|
|
44
|
+
it "sanitizes credit card number and cvv with newlines" do
|
45
|
+
input_xml = <<-END
|
46
|
+
<customer>
|
47
|
+
<first-name>Joe</first-name>
|
48
|
+
<last-name>Doe</last-name>
|
49
|
+
<number>123456000\n0001234</number>
|
50
|
+
<cvv>1\n23</cvv>
|
51
|
+
</customer>
|
52
|
+
END
|
53
|
+
|
54
|
+
expected_xml = <<-END
|
55
|
+
[Braintree] <customer>
|
56
|
+
[Braintree] <first-name>Joe</first-name>
|
57
|
+
[Braintree] <last-name>Doe</last-name>
|
58
|
+
[Braintree] <number>123456******1234</number>
|
59
|
+
[Braintree] <cvv>***</cvv>
|
60
|
+
[Braintree] </customer>
|
61
|
+
END
|
62
|
+
Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "self._http_do" do
|
42
67
|
it "connects when proxy address is specified" do
|
43
68
|
config = Braintree::Configuration.new(
|
44
69
|
:proxy_address => "localhost",
|
45
70
|
:proxy_port => 8080,
|
46
71
|
:proxy_user => "user",
|
47
|
-
:proxy_pass => "test"
|
72
|
+
:proxy_pass => "test",
|
48
73
|
)
|
49
74
|
|
50
75
|
http = Braintree::Http.new(config)
|
@@ -52,7 +77,7 @@ END
|
|
52
77
|
"Net::HTTP",
|
53
78
|
:open_timeout= => nil,
|
54
79
|
:read_timeout= => nil,
|
55
|
-
:start => nil
|
80
|
+
:start => nil,
|
56
81
|
)
|
57
82
|
|
58
83
|
Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
|
@@ -63,7 +88,7 @@ END
|
|
63
88
|
it "accepts a partially specified proxy" do
|
64
89
|
config = Braintree::Configuration.new(
|
65
90
|
:proxy_address => "localhost",
|
66
|
-
:proxy_port => 8080
|
91
|
+
:proxy_port => 8080,
|
67
92
|
)
|
68
93
|
|
69
94
|
http = Braintree::Http.new(config)
|
@@ -71,7 +96,7 @@ END
|
|
71
96
|
"Net::HTTP",
|
72
97
|
:open_timeout= => nil,
|
73
98
|
:read_timeout= => nil,
|
74
|
-
:start => nil
|
99
|
+
:start => nil,
|
75
100
|
)
|
76
101
|
|
77
102
|
Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
|
@@ -86,7 +111,7 @@ END
|
|
86
111
|
"Net::HTTP",
|
87
112
|
:open_timeout= => nil,
|
88
113
|
:read_timeout= => nil,
|
89
|
-
:start => nil
|
114
|
+
:start => nil,
|
90
115
|
)
|
91
116
|
|
92
117
|
Net::HTTP.should_receive(:new).with(nil, nil).and_return(net_http_instance)
|
@@ -95,6 +120,69 @@ END
|
|
95
120
|
end
|
96
121
|
end
|
97
122
|
|
123
|
+
describe "_compose_headers" do
|
124
|
+
before (:each) do
|
125
|
+
config = Braintree::Configuration.new
|
126
|
+
@http = Braintree::Http.new(config)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "returns a hash of default headers" do
|
130
|
+
default_headers = @http._compose_headers
|
131
|
+
expect(default_headers["Accept"]).to eq("application/xml")
|
132
|
+
expect(default_headers["Accept-Encoding"]).to eq("gzip")
|
133
|
+
expect(default_headers["Content-Type"]).to eq("application/xml")
|
134
|
+
expect(default_headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
135
|
+
expect(default_headers["X-ApiVersion"]).to eq("6")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "overwrites defaults with override headers" do
|
139
|
+
override_headers = {
|
140
|
+
"Accept" => "application/pdf",
|
141
|
+
"Authorization" => "token"
|
142
|
+
}
|
143
|
+
headers = @http._compose_headers(override_headers)
|
144
|
+
expect(headers["Accept"]).to eq("application/pdf")
|
145
|
+
expect(headers["Accept-Encoding"]).to eq("gzip")
|
146
|
+
expect(headers["Authorization"]).to eq("token")
|
147
|
+
expect(headers["Content-Type"]).to eq("application/xml")
|
148
|
+
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
149
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "extends default headers when new headers are specified" do
|
153
|
+
override_headers = {
|
154
|
+
"New-Header" => "New Value"
|
155
|
+
}
|
156
|
+
headers = @http._compose_headers(override_headers)
|
157
|
+
expect(headers["Accept"]).to eq("application/xml")
|
158
|
+
expect(headers["Accept-Encoding"]).to eq("gzip")
|
159
|
+
expect(headers["Content-Type"]).to eq("application/xml")
|
160
|
+
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
161
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
162
|
+
expect(headers["New-Header"]).to eq("New Value")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "_setup_connection" do
|
167
|
+
it "creates a new Net::HTTP object using default server and port" do
|
168
|
+
config = Braintree::Configuration.new
|
169
|
+
http = Braintree::Http.new(config)
|
170
|
+
|
171
|
+
connection = http._setup_connection
|
172
|
+
expect(connection.address).to eq(nil)
|
173
|
+
expect(connection.port).to eq(80)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "overrides the default server and port when replacements are specified" do
|
177
|
+
config = Braintree::Configuration.new
|
178
|
+
http = Braintree::Http.new(config)
|
179
|
+
|
180
|
+
connection = http._setup_connection("localhost", 3443)
|
181
|
+
expect(connection.address).to eq("localhost")
|
182
|
+
expect(connection.port).to eq(3443)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
98
186
|
describe "_build_query_string" do
|
99
187
|
it "returns an empty string for empty query params" do
|
100
188
|
Braintree::Http.new(:config)._build_query_string({}).should == ""
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::LocalPaymentCompleted do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::LocalPaymentCompleted.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
params = {
|
15
|
+
payment_id: "a-payment-id",
|
16
|
+
payer_id: "a-payer-id",
|
17
|
+
payment_method_nonce: "a-nonce",
|
18
|
+
transaction: {
|
19
|
+
id: "a-transaction-id",
|
20
|
+
amount: "31.00",
|
21
|
+
order_id: "an-order-id",
|
22
|
+
status: Braintree::Transaction::Status::Authorized,
|
23
|
+
},
|
24
|
+
}
|
25
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
26
|
+
|
27
|
+
local_payment_completed.payment_id.should eq("a-payment-id")
|
28
|
+
local_payment_completed.payer_id.should eq("a-payer-id")
|
29
|
+
local_payment_completed.payment_method_nonce.should eq("a-nonce")
|
30
|
+
local_payment_completed.transaction.id.should eq("a-transaction-id")
|
31
|
+
local_payment_completed.transaction.amount.should eq(31.0)
|
32
|
+
local_payment_completed.transaction.order_id.should eq("an-order-id")
|
33
|
+
local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "initializes the object with the appropriate attributes set if no transaction is provided" do
|
37
|
+
params = {
|
38
|
+
payment_id: "a-payment-id",
|
39
|
+
payer_id: "a-payer-id",
|
40
|
+
payment_method_nonce: "a-nonce",
|
41
|
+
}
|
42
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
43
|
+
|
44
|
+
local_payment_completed.payment_id.should eq("a-payment-id")
|
45
|
+
local_payment_completed.payer_id.should eq("a-payer-id")
|
46
|
+
local_payment_completed.payment_method_nonce.should eq("a-nonce")
|
47
|
+
local_payment_completed.transaction.should be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::LocalPaymentExpired do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::LocalPaymentExpired.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
params = {
|
15
|
+
payment_id: "a-payment-id",
|
16
|
+
payment_context_id: "a-payment-context-id",
|
17
|
+
}
|
18
|
+
local_payment_expired = Braintree::LocalPaymentExpired._new(params)
|
19
|
+
|
20
|
+
local_payment_expired.payment_id.should eq("a-payment-id")
|
21
|
+
local_payment_expired.payment_context_id.should eq("a-payment-context-id")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::LocalPaymentFunded do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::LocalPaymentFunded.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
params = {
|
15
|
+
payment_id: "a-payment-id",
|
16
|
+
payment_context_id: "a-payment-context-id",
|
17
|
+
transaction: {
|
18
|
+
id: "a-transaction-id",
|
19
|
+
amount: "31.00",
|
20
|
+
order_id: "an-order-id",
|
21
|
+
status: Braintree::Transaction::Status::Settled,
|
22
|
+
},
|
23
|
+
}
|
24
|
+
local_payment_funded = Braintree::LocalPaymentFunded._new(params)
|
25
|
+
|
26
|
+
local_payment_funded.payment_id.should eq("a-payment-id")
|
27
|
+
local_payment_funded.payment_context_id.should eq("a-payment-context-id")
|
28
|
+
local_payment_funded.transaction.id.should eq("a-transaction-id")
|
29
|
+
local_payment_funded.transaction.amount.should eq(31.0)
|
30
|
+
local_payment_funded.transaction.order_id.should eq("an-order-id")
|
31
|
+
local_payment_funded.transaction.status.should eq(Braintree::Transaction::Status::Settled)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -13,7 +13,7 @@ describe Braintree::MerchantAccount do
|
|
13
13
|
nil,
|
14
14
|
:id => "merchant_account",
|
15
15
|
:status => "active",
|
16
|
-
:master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil}
|
16
|
+
:master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil},
|
17
17
|
)
|
18
18
|
|
19
19
|
master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
|
@@ -2,6 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
2
|
|
3
3
|
describe Braintree::Modification do
|
4
4
|
it "converts string amount" do
|
5
|
-
Braintree::Modification._new(:amount => "100.00").amount.should == BigDecimal
|
5
|
+
Braintree::Modification._new(:amount => "100.00").amount.should == BigDecimal("100.00")
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::PaymentMethodCustomerDataUpdatedMetadata.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
|
15
|
+
params = {
|
16
|
+
token: "a-token",
|
17
|
+
payment_method: {
|
18
|
+
venmo_account: {
|
19
|
+
venmo_user_id: "venmo-user-id",
|
20
|
+
},
|
21
|
+
},
|
22
|
+
datetime_updated: "2022-01-01T21:28:37Z",
|
23
|
+
enriched_customer_data: {
|
24
|
+
fields_updated: ["username"],
|
25
|
+
profile_data: {
|
26
|
+
username: "a-username",
|
27
|
+
first_name: "a-first-name",
|
28
|
+
last_name: "a-last-name",
|
29
|
+
phone_number: "a-phone-number",
|
30
|
+
email: "a-email",
|
31
|
+
},
|
32
|
+
},
|
33
|
+
}
|
34
|
+
|
35
|
+
payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
|
36
|
+
|
37
|
+
payment_method_customer_data_updated.token.should eq("a-token")
|
38
|
+
payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
|
39
|
+
payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
|
40
|
+
payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
|
41
|
+
payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
|
42
|
+
payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::PaymentMethodNonceDetailsPayerInfo do
|
4
|
+
let(:payment_method_nonce_details_payer_info) {
|
5
|
+
Braintree::PaymentMethodNonceDetailsPayerInfo.new(
|
6
|
+
:billing_agreement_id => "billing-agreement-id",
|
7
|
+
:country_code => "US",
|
8
|
+
:email => "test@example.com",
|
9
|
+
:first_name => "First",
|
10
|
+
:last_name => "Last",
|
11
|
+
:payer_id => "payer-id",
|
12
|
+
)
|
13
|
+
}
|
14
|
+
|
15
|
+
describe "#initialize" do
|
16
|
+
it "sets attributes" do
|
17
|
+
payment_method_nonce_details_payer_info.billing_agreement_id.should == "billing-agreement-id"
|
18
|
+
payment_method_nonce_details_payer_info.country_code.should == "US"
|
19
|
+
payment_method_nonce_details_payer_info.email.should == "test@example.com"
|
20
|
+
payment_method_nonce_details_payer_info.first_name.should == "First"
|
21
|
+
payment_method_nonce_details_payer_info.last_name.should == "Last"
|
22
|
+
payment_method_nonce_details_payer_info.payer_id.should == "payer-id"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "inspect" do
|
27
|
+
it "prints the attributes" do
|
28
|
+
payment_method_nonce_details_payer_info.inspect.should == %(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|