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
data/spec/spec_helper.rb
CHANGED
@@ -3,8 +3,9 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
3
3
|
project_root = File.expand_path(File.dirname(__FILE__) + "/..")
|
4
4
|
require "rubygems"
|
5
5
|
require "bundler/setup"
|
6
|
-
require "rspec"
|
7
6
|
require "libxml"
|
7
|
+
require "rspec"
|
8
|
+
require "pry"
|
8
9
|
|
9
10
|
braintree_lib = "#{project_root}/lib"
|
10
11
|
$LOAD_PATH << braintree_lib
|
@@ -27,10 +28,6 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
def now_in_eastern
|
31
|
-
(Time.now.utc - 5*60*60).strftime("%Y-%m-%d")
|
32
|
-
end
|
33
|
-
|
34
31
|
module SpecHelper
|
35
32
|
|
36
33
|
DefaultMerchantAccountId = "sandbox_credit_card"
|
@@ -39,13 +36,18 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
39
36
|
ThreeDSecureMerchantAccountId = "three_d_secure_merchant_account"
|
40
37
|
FakeAmexDirectMerchantAccountId = "fake_amex_direct_usd"
|
41
38
|
FakeVenmoAccountMerchantAccountId = "fake_first_data_venmo_account"
|
42
|
-
|
43
|
-
|
39
|
+
UsBankMerchantAccountId = "us_bank_merchant_account"
|
40
|
+
AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
|
41
|
+
AdyenMerchantAccountId = "adyen_ma"
|
42
|
+
HiperBRLMerchantAccountId = "hiper_brl"
|
43
|
+
CardProcessorBRLMerchantAccountId = "card_processor_brl"
|
44
|
+
FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
|
45
|
+
AibSwedenMaMerchantAccountId = "aib_swe_ma"
|
44
46
|
|
45
47
|
TrialPlan = {
|
46
48
|
:description => "Plan for integration tests -- with trial",
|
47
49
|
:id => "integration_trial_plan",
|
48
|
-
:price => BigDecimal
|
50
|
+
:price => BigDecimal("43.21"),
|
49
51
|
:trial_period => true,
|
50
52
|
:trial_duration => 2,
|
51
53
|
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Day
|
@@ -54,14 +56,14 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
54
56
|
TriallessPlan = {
|
55
57
|
:description => "Plan for integration tests -- without a trial",
|
56
58
|
:id => "integration_trialless_plan",
|
57
|
-
:price => BigDecimal
|
59
|
+
:price => BigDecimal("12.34"),
|
58
60
|
:trial_period => false
|
59
61
|
}
|
60
62
|
|
61
63
|
AddOnDiscountPlan = {
|
62
64
|
:description => "Plan for integration tests -- with add-ons and discounts",
|
63
65
|
:id => "integration_plan_with_add_ons_and_discounts",
|
64
|
-
:price => BigDecimal
|
66
|
+
:price => BigDecimal("9.99"),
|
65
67
|
:trial_period => true,
|
66
68
|
:trial_duration => 2,
|
67
69
|
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Day
|
@@ -70,7 +72,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
70
72
|
BillingDayOfMonthPlan = {
|
71
73
|
:description => "Plan for integration tests -- with billing day of month",
|
72
74
|
:id => "integration_plan_with_billing_day_of_month",
|
73
|
-
:price => BigDecimal
|
75
|
+
:price => BigDecimal("8.88"),
|
74
76
|
:billing_day_of_month => 5
|
75
77
|
}
|
76
78
|
|
@@ -89,13 +91,13 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
89
91
|
:environment => Braintree::Configuration.environment,
|
90
92
|
:merchant_id => "test_merchant_id",
|
91
93
|
:public_key => "test_public_key",
|
92
|
-
:private_key => "test_private_key"
|
94
|
+
:private_key => "test_private_key",
|
93
95
|
)
|
94
96
|
|
95
97
|
def self.make_past_due(subscription, number_of_days_past_due = 1)
|
96
98
|
config = Braintree::Configuration.instantiate
|
97
99
|
config.http.put(
|
98
|
-
"#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}"
|
100
|
+
"#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}",
|
99
101
|
)
|
100
102
|
end
|
101
103
|
|
@@ -107,14 +109,14 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
107
109
|
def self.create_3ds_verification(merchant_account_id, params)
|
108
110
|
config = Braintree::Configuration.instantiate
|
109
111
|
response = config.http.post("#{config.base_merchant_path}/three_d_secure/create_verification/#{merchant_account_id}", :three_d_secure_verification => params)
|
110
|
-
response[:three_d_secure_verification][:
|
112
|
+
response[:three_d_secure_verification][:three_d_secure_authentication_id]
|
111
113
|
end
|
112
114
|
|
113
115
|
def self.create_merchant(params={})
|
114
116
|
gateway = Braintree::Gateway.new(
|
115
117
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
116
118
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
117
|
-
:logger => Logger.new("/dev/null")
|
119
|
+
:logger => Logger.new("/dev/null"),
|
118
120
|
)
|
119
121
|
|
120
122
|
gateway.merchant.create({
|
@@ -145,8 +147,9 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
145
147
|
def self.simulate_form_post_for_tr(tr_data_string, form_data_hash, url = Braintree::TransparentRedirect.url)
|
146
148
|
response = nil
|
147
149
|
config = Braintree::Configuration.instantiate
|
148
|
-
Net::HTTP.
|
149
|
-
|
150
|
+
http = Net::HTTP.new(config.server, config.port)
|
151
|
+
http.use_ssl = config.ssl?
|
152
|
+
http.start do |http|
|
150
153
|
request = Net::HTTP::Post.new("/" + url.split("/", 4)[3])
|
151
154
|
request.add_field "Content-Type", "application/x-www-form-urlencoded"
|
152
155
|
request.body = Braintree::Util.hash_to_query_string({:tr_data => tr_data_string}.merge(form_data_hash))
|
@@ -184,16 +187,11 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
184
187
|
end
|
185
188
|
|
186
189
|
def matches?(xml_string)
|
187
|
-
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string
|
188
|
-
@rexml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string, Braintree::Xml::Rexml)
|
190
|
+
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
|
189
191
|
if @libxml_parse != @expected_hash
|
190
192
|
@results = @libxml_parse
|
191
193
|
@failed_parser = "libxml"
|
192
194
|
false
|
193
|
-
elsif @rexml_parse != @expected_hash
|
194
|
-
@results = @rexml_parse
|
195
|
-
@failed_parser = "rexml"
|
196
|
-
false
|
197
195
|
else
|
198
196
|
true
|
199
197
|
end
|
@@ -217,6 +215,11 @@ end
|
|
217
215
|
RSpec.configure do |config|
|
218
216
|
config.include CustomMatchers
|
219
217
|
|
218
|
+
if ENV["JUNIT"] == "1"
|
219
|
+
config.add_formatter("RspecJunitFormatter", "tmp/build/braintree-ruby.#{rand}.junit.xml")
|
220
|
+
config.add_formatter("progress")
|
221
|
+
end
|
222
|
+
|
220
223
|
config.expect_with :rspec do |expect|
|
221
224
|
expect.syntax = [:should, :expect]
|
222
225
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
3
3
|
describe Braintree::Address do
|
4
4
|
describe "==" do
|
5
5
|
it "returns true if given an address with the same id and customer_id" do
|
6
|
-
first = Braintree::Address._new(:gateway, :customer_id => "c1", :id =>
|
6
|
+
first = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
|
7
7
|
second = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
|
8
8
|
|
9
9
|
first.should == second
|
@@ -94,12 +94,4 @@ describe Braintree::Address do
|
|
94
94
|
end.to raise_error(NoMethodError, /protected method .new/)
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
98
|
-
describe "update" do
|
99
|
-
it "raises an exception if hash includes an invalid key" do
|
100
|
-
expect do
|
101
|
-
Braintree::Address._new(Braintree::Configuration.gateway, {}).update(:street_address => "456 E Main", :invalid_key2 => "foo")
|
102
|
-
end.to raise_error(ArgumentError, "invalid keys: invalid_key2")
|
103
|
-
end
|
104
|
-
end
|
105
97
|
end
|
@@ -1,23 +1,123 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
3
|
describe Braintree::ApplePayCard do
|
4
|
+
let(:attributes) do
|
5
|
+
{
|
6
|
+
:billing_address => {
|
7
|
+
company: "Braintree",
|
8
|
+
country_code_alpha2: "US",
|
9
|
+
country_code_alpha3: "USA",
|
10
|
+
country_code_numeric: "840",
|
11
|
+
country_name: "United States of America",
|
12
|
+
extended_address: "Apt 1",
|
13
|
+
first_name: "John",
|
14
|
+
last_name: "Miller",
|
15
|
+
locality: "Chicago",
|
16
|
+
phone_number: "17708675309",
|
17
|
+
postal_code: "12345",
|
18
|
+
region: "Illinois",
|
19
|
+
street_address: "123 Sesame Street",
|
20
|
+
},
|
21
|
+
:bin => "411111",
|
22
|
+
:card_type => "Apple Pay - MasterCard",
|
23
|
+
:cardholder_name => "John Miller",
|
24
|
+
:commercial => "No",
|
25
|
+
:country_of_issuance => "USA",
|
26
|
+
:created_at => Time.now,
|
27
|
+
:customer_id => "cid1",
|
28
|
+
:debit => "No",
|
29
|
+
:default => true,
|
30
|
+
:durbin_regulated => "Yes",
|
31
|
+
:expiration_month => "01",
|
32
|
+
:expiration_year => "2025",
|
33
|
+
:expired => false,
|
34
|
+
:healthcare => "No",
|
35
|
+
:image_url => nil,
|
36
|
+
:issuing_bank => "Big Bad Bank",
|
37
|
+
:last_4 => "9876",
|
38
|
+
:payment_instrument_name => nil,
|
39
|
+
:payroll => "No",
|
40
|
+
:prepaid => "No",
|
41
|
+
:product_id => "MAC",
|
42
|
+
:source_description => "blah",
|
43
|
+
:subscriptions => [
|
44
|
+
{
|
45
|
+
balance: "50.00",
|
46
|
+
price: "10.00",
|
47
|
+
descriptor: [],
|
48
|
+
transactions: [],
|
49
|
+
add_ons: [],
|
50
|
+
discounts: [],
|
51
|
+
},
|
52
|
+
],
|
53
|
+
:token => "123456789",
|
54
|
+
:updated_at => Time.now,
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "initialize" do
|
59
|
+
it "converts billing address hash to Braintree::Address object" do
|
60
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
61
|
+
|
62
|
+
expect(card.billing_address).to be_instance_of(Braintree::Address)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "converts subscriptions hash to Braintree::Subscription object" do
|
66
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
67
|
+
|
68
|
+
expect(card.subscriptions[0]).to be_instance_of(Braintree::Subscription)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "handles nil billing address" do
|
72
|
+
attributes.delete(:billing_address)
|
73
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
74
|
+
|
75
|
+
expect(card.billing_address).to be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it "handles nil subscriptions" do
|
79
|
+
attributes.delete(:subscriptions)
|
80
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
81
|
+
|
82
|
+
expect(card.subscriptions).to be_empty
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
4
86
|
describe "default?" do
|
5
87
|
it "is true if the Apple pay card is the default payment method for the customer" do
|
6
|
-
Braintree::ApplePayCard._new(:gateway,
|
88
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
89
|
+
|
90
|
+
expect(card.default?).to be true
|
7
91
|
end
|
8
92
|
|
9
93
|
it "is false if the Apple pay card is not the default payment methodfor the customer" do
|
10
|
-
|
94
|
+
attributes.merge!(:default => false)
|
95
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
96
|
+
|
97
|
+
expect(card.default?).to be false
|
11
98
|
end
|
12
99
|
end
|
13
100
|
|
14
101
|
describe "expired?" do
|
15
102
|
it "is true if the Apple pay card is expired" do
|
16
|
-
|
103
|
+
attributes.merge!(:expired => true)
|
104
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
105
|
+
|
106
|
+
expect(card.expired?).to be true
|
17
107
|
end
|
18
108
|
|
19
109
|
it "is false if the Apple pay card is not expired" do
|
20
|
-
Braintree::ApplePayCard._new(:gateway,
|
110
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
111
|
+
|
112
|
+
expect(card.expired?).to be false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "self.new" do
|
117
|
+
it "is protected" do
|
118
|
+
expect do
|
119
|
+
Braintree::ApplePayCard.new
|
120
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
21
121
|
end
|
22
122
|
end
|
23
123
|
end
|
@@ -16,7 +16,7 @@ module Braintree
|
|
16
16
|
expect {
|
17
17
|
client_token = Braintree::ClientToken.generate(
|
18
18
|
:public_key => "bad_key",
|
19
|
-
:created_at => "bad_time"
|
19
|
+
:created_at => "bad_time",
|
20
20
|
)
|
21
21
|
}.to raise_error(ArgumentError, /created_at, public_key/)
|
22
22
|
end
|
@@ -27,7 +27,7 @@ module Braintree
|
|
27
27
|
it "raises an ArgumentError if #{option_name} is present" do
|
28
28
|
expect do
|
29
29
|
Braintree::ClientToken.generate(
|
30
|
-
option_name.to_sym => true
|
30
|
+
option_name.to_sym => true,
|
31
31
|
)
|
32
32
|
end.to raise_error(ArgumentError, /#{option_name}/)
|
33
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "stringio"
|
2
|
+
|
1
3
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
4
|
|
3
5
|
describe Braintree::Configuration do
|
@@ -20,26 +22,26 @@ describe Braintree::Configuration do
|
|
20
22
|
describe "initialize" do
|
21
23
|
it "accepts merchant credentials" do
|
22
24
|
config = Braintree::Configuration.new(
|
23
|
-
:merchant_id =>
|
24
|
-
:public_key =>
|
25
|
-
:private_key =>
|
25
|
+
:merchant_id => "merchant_id",
|
26
|
+
:public_key => "public_key",
|
27
|
+
:private_key => "private_key",
|
26
28
|
)
|
27
29
|
|
28
|
-
config.merchant_id.should ==
|
29
|
-
config.public_key.should ==
|
30
|
-
config.private_key.should ==
|
30
|
+
config.merchant_id.should == "merchant_id"
|
31
|
+
config.public_key.should == "public_key"
|
32
|
+
config.private_key.should == "private_key"
|
31
33
|
end
|
32
34
|
|
33
35
|
it "accepts partner credentials" do
|
34
36
|
config = Braintree::Configuration.new(
|
35
|
-
:partner_id =>
|
36
|
-
:public_key =>
|
37
|
-
:private_key =>
|
37
|
+
:partner_id => "partner_id",
|
38
|
+
:public_key => "public_key",
|
39
|
+
:private_key => "private_key",
|
38
40
|
)
|
39
41
|
|
40
|
-
config.merchant_id.should ==
|
41
|
-
config.public_key.should ==
|
42
|
-
config.private_key.should ==
|
42
|
+
config.merchant_id.should == "partner_id"
|
43
|
+
config.public_key.should == "public_key"
|
44
|
+
config.private_key.should == "private_key"
|
43
45
|
end
|
44
46
|
|
45
47
|
it "raises if combining client_id/secret with access_token" do
|
@@ -47,7 +49,7 @@ describe Braintree::Configuration do
|
|
47
49
|
Braintree::Configuration.new(
|
48
50
|
:client_id => "client_id$development$integration_client_id",
|
49
51
|
:client_secret => "client_secret$development$integration_client_secret",
|
50
|
-
:access_token => "access_token$development$integration_merchant_id$fb27c79dd"
|
52
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
51
53
|
)
|
52
54
|
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
53
55
|
end
|
@@ -60,28 +62,55 @@ describe Braintree::Configuration do
|
|
60
62
|
:merchant_id => "merchant_id",
|
61
63
|
:public_key => "public_key",
|
62
64
|
:private_key => "private_key",
|
63
|
-
:environment => "development"
|
65
|
+
:environment => "development",
|
64
66
|
)
|
65
67
|
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
66
68
|
end
|
67
69
|
|
70
|
+
context "mixed environments" do
|
71
|
+
before do
|
72
|
+
@original_stderr = $stderr
|
73
|
+
$stderr = StringIO.new
|
74
|
+
end
|
75
|
+
|
76
|
+
after do
|
77
|
+
$stderr = @original_stderr
|
78
|
+
end
|
79
|
+
|
80
|
+
it "warns if both environment and access_token are provided and their environments differ" do
|
81
|
+
Braintree::Configuration.new(
|
82
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
83
|
+
:environment => "sandbox",
|
84
|
+
)
|
85
|
+
$stderr.string.should == "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used.\n"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "does not warn if both environment and access_token are provided and their environments match" do
|
89
|
+
Braintree::Configuration.new(
|
90
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
91
|
+
:environment => "development",
|
92
|
+
)
|
93
|
+
$stderr.string.should == ""
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
68
97
|
it "accepts proxy params" do
|
69
98
|
config = Braintree::Configuration.new(
|
70
|
-
:proxy_address =>
|
99
|
+
:proxy_address => "localhost",
|
71
100
|
:proxy_port => 8080,
|
72
|
-
:proxy_user =>
|
73
|
-
:proxy_pass =>
|
101
|
+
:proxy_user => "user",
|
102
|
+
:proxy_pass => "test",
|
74
103
|
)
|
75
104
|
|
76
|
-
config.proxy_address.should ==
|
105
|
+
config.proxy_address.should == "localhost"
|
77
106
|
config.proxy_port.should == 8080
|
78
|
-
config.proxy_user.should ==
|
79
|
-
config.proxy_pass.should ==
|
107
|
+
config.proxy_user.should == "user"
|
108
|
+
config.proxy_pass.should == "test"
|
80
109
|
end
|
81
110
|
|
82
111
|
it "accepts ssl version" do
|
83
112
|
config = Braintree::Configuration.new(
|
84
|
-
:ssl_version => :TLSv1_2
|
113
|
+
:ssl_version => :TLSv1_2,
|
85
114
|
)
|
86
115
|
|
87
116
|
config.ssl_version.should == :TLSv1_2
|
@@ -117,14 +146,14 @@ describe Braintree::Configuration do
|
|
117
146
|
Braintree::Configuration.environment = :sandbox
|
118
147
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
119
148
|
ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
|
120
|
-
File.
|
149
|
+
File.exist?(ca_file).should == true
|
121
150
|
end
|
122
151
|
|
123
152
|
it "production" do
|
124
153
|
Braintree::Configuration.environment = :production
|
125
154
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
126
155
|
ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
|
127
|
-
File.
|
156
|
+
File.exist?(ca_file).should == true
|
128
157
|
end
|
129
158
|
end
|
130
159
|
|
@@ -138,6 +167,19 @@ describe Braintree::Configuration do
|
|
138
167
|
config = Braintree::Configuration.new :logger => nil
|
139
168
|
config.logger.should_not == nil
|
140
169
|
end
|
170
|
+
|
171
|
+
it "can set logger on gateway instance" do
|
172
|
+
gateway = Braintree::Configuration.gateway
|
173
|
+
old_logger = Braintree::Configuration.logger
|
174
|
+
|
175
|
+
new_logger = Logger.new("/dev/null")
|
176
|
+
|
177
|
+
gateway.config.logger = new_logger
|
178
|
+
|
179
|
+
expect(gateway.config.logger).to eq(new_logger)
|
180
|
+
|
181
|
+
gateway.config.logger = old_logger
|
182
|
+
end
|
141
183
|
end
|
142
184
|
|
143
185
|
describe "self.environment" do
|
@@ -154,6 +196,14 @@ describe Braintree::Configuration do
|
|
154
196
|
Braintree::Configuration.environment
|
155
197
|
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.environment needs to be set")
|
156
198
|
end
|
199
|
+
|
200
|
+
it "converts environment to symbol" do
|
201
|
+
config = Braintree::Configuration.new({
|
202
|
+
:environment => "sandbox"
|
203
|
+
})
|
204
|
+
|
205
|
+
expect(config.environment).to eq(:sandbox)
|
206
|
+
end
|
157
207
|
end
|
158
208
|
|
159
209
|
describe "self.gateway" do
|
@@ -188,12 +238,12 @@ describe Braintree::Configuration do
|
|
188
238
|
|
189
239
|
it "allows the environment to be set with a string value" do
|
190
240
|
expect do
|
191
|
-
Braintree::Configuration.environment =
|
241
|
+
Braintree::Configuration.environment = "sandbox"
|
192
242
|
end.not_to raise_error
|
193
243
|
end
|
194
244
|
|
195
245
|
it "sets the environment as a symbol" do
|
196
|
-
Braintree::Configuration.environment =
|
246
|
+
Braintree::Configuration.environment = "sandbox"
|
197
247
|
expect(Braintree::Configuration.environment).to eq :sandbox
|
198
248
|
end
|
199
249
|
end
|
@@ -276,15 +326,15 @@ describe Braintree::Configuration do
|
|
276
326
|
|
277
327
|
it "is 3000 or GATEWAY_PORT environment variable for development" do
|
278
328
|
Braintree::Configuration.environment = :development
|
279
|
-
old_gateway_port = ENV[
|
329
|
+
old_gateway_port = ENV["GATEWAY_PORT"]
|
280
330
|
begin
|
281
|
-
ENV[
|
331
|
+
ENV["GATEWAY_PORT"] = nil
|
282
332
|
Braintree::Configuration.instantiate.port.should == 3000
|
283
333
|
|
284
|
-
ENV[
|
285
|
-
Braintree::Configuration.instantiate.port.should ==
|
334
|
+
ENV["GATEWAY_PORT"] = "1234"
|
335
|
+
Braintree::Configuration.instantiate.port.should == "1234"
|
286
336
|
ensure
|
287
|
-
ENV[
|
337
|
+
ENV["GATEWAY_PORT"] = old_gateway_port
|
288
338
|
end
|
289
339
|
end
|
290
340
|
end
|
@@ -306,10 +356,35 @@ describe Braintree::Configuration do
|
|
306
356
|
end
|
307
357
|
end
|
308
358
|
|
359
|
+
describe "graphql_server" do
|
360
|
+
it "is localhost or GRAPHQL_HOST environment variable for development" do
|
361
|
+
Braintree::Configuration.environment = :development
|
362
|
+
old_gateway_url = ENV["GRAPHQL_HOST"]
|
363
|
+
begin
|
364
|
+
ENV["GRAPHQL_HOST"] = nil
|
365
|
+
Braintree::Configuration.instantiate.graphql_server.should == "graphql.bt.local"
|
366
|
+
|
367
|
+
ENV["GRAPHQL_HOST"] = "gateway"
|
368
|
+
Braintree::Configuration.instantiate.graphql_server.should == "gateway"
|
369
|
+
ensure
|
370
|
+
ENV["GRAPHQL_HOST"] = old_gateway_url
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
309
375
|
describe "server" do
|
310
|
-
it "is localhost for development" do
|
376
|
+
it "is localhost or GATEWAY_HOST environment variable for development" do
|
311
377
|
Braintree::Configuration.environment = :development
|
312
|
-
|
378
|
+
old_gateway_url = ENV["GATEWAY_HOST"]
|
379
|
+
begin
|
380
|
+
ENV["GATEWAY_HOST"] = nil
|
381
|
+
Braintree::Configuration.instantiate.server.should == "localhost"
|
382
|
+
|
383
|
+
ENV["GATEWAY_HOST"] = "gateway"
|
384
|
+
Braintree::Configuration.instantiate.server.should == "gateway"
|
385
|
+
ensure
|
386
|
+
ENV["GATEWAY_HOST"] = old_gateway_url
|
387
|
+
end
|
313
388
|
end
|
314
389
|
|
315
390
|
it "is api.braintreegateway.com for production" do
|
@@ -393,7 +468,7 @@ describe Braintree::Configuration do
|
|
393
468
|
it "masks the private_key" do
|
394
469
|
config = Braintree::Configuration.new(:private_key => "secret_key")
|
395
470
|
config.inspect.should include('@private_key="[FILTERED]"')
|
396
|
-
config.inspect.should_not include(
|
471
|
+
config.inspect.should_not include("secret_key")
|
397
472
|
end
|
398
473
|
end
|
399
474
|
|