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
@@ -5,7 +5,7 @@ describe "OAuth" do
|
|
5
5
|
@gateway = Braintree::Gateway.new(
|
6
6
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
7
7
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
8
|
-
:logger => Logger.new("/dev/null")
|
8
|
+
:logger => Logger.new("/dev/null"),
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
@@ -18,7 +18,7 @@ describe "OAuth" do
|
|
18
18
|
|
19
19
|
result = @gateway.oauth.create_token_from_code(
|
20
20
|
:code => code,
|
21
|
-
:scope => "read_write"
|
21
|
+
:scope => "read_write",
|
22
22
|
)
|
23
23
|
|
24
24
|
result.should be_success
|
@@ -32,7 +32,7 @@ describe "OAuth" do
|
|
32
32
|
it "returns validation errors for bad params" do
|
33
33
|
result = @gateway.oauth.create_token_from_code(
|
34
34
|
:code => "bad_code",
|
35
|
-
:scope => "read_write"
|
35
|
+
:scope => "read_write",
|
36
36
|
)
|
37
37
|
|
38
38
|
result.should_not be_success
|
@@ -43,13 +43,13 @@ describe "OAuth" do
|
|
43
43
|
it "raises with a helpful error if client_id and client_secret are not set" do
|
44
44
|
gateway = Braintree::Gateway.new(
|
45
45
|
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
46
|
-
:logger => Logger.new("/dev/null")
|
46
|
+
:logger => Logger.new("/dev/null"),
|
47
47
|
)
|
48
48
|
|
49
49
|
expect do
|
50
50
|
gateway.oauth.create_token_from_code(
|
51
51
|
:code => "some code",
|
52
|
-
:scope => "read_write"
|
52
|
+
:scope => "read_write",
|
53
53
|
)
|
54
54
|
end.to raise_error(Braintree::ConfigurationError, /client_id and client_secret are required/);
|
55
55
|
end
|
@@ -63,12 +63,12 @@ describe "OAuth" do
|
|
63
63
|
})
|
64
64
|
refresh_token = @gateway.oauth.create_token_from_code(
|
65
65
|
:code => code,
|
66
|
-
:scope => "read_write"
|
66
|
+
:scope => "read_write",
|
67
67
|
).credentials.refresh_token
|
68
68
|
|
69
69
|
result = @gateway.oauth.create_token_from_refresh_token(
|
70
70
|
:refresh_token => refresh_token,
|
71
|
-
:scope => "read_write"
|
71
|
+
:scope => "read_write",
|
72
72
|
)
|
73
73
|
|
74
74
|
result.should be_success
|
@@ -88,7 +88,7 @@ describe "OAuth" do
|
|
88
88
|
})
|
89
89
|
access_token = @gateway.oauth.create_token_from_code(
|
90
90
|
:code => code,
|
91
|
-
:scope => "read_write"
|
91
|
+
:scope => "read_write",
|
92
92
|
).credentials.access_token
|
93
93
|
|
94
94
|
result = @gateway.oauth.revoke_access_token(access_token)
|
@@ -96,7 +96,7 @@ describe "OAuth" do
|
|
96
96
|
|
97
97
|
gateway = Braintree::Gateway.new(
|
98
98
|
:access_token => access_token,
|
99
|
-
:logger => Logger.new("/dev/null")
|
99
|
+
:logger => Logger.new("/dev/null"),
|
100
100
|
)
|
101
101
|
|
102
102
|
expect do
|
@@ -113,6 +113,7 @@ describe "OAuth" do
|
|
113
113
|
:scope => "read_write",
|
114
114
|
:state => "baz_state",
|
115
115
|
:landing_page => "signup",
|
116
|
+
:login_only => false,
|
116
117
|
:user => {
|
117
118
|
:country => "USA",
|
118
119
|
:email => "foo@example.com",
|
@@ -145,7 +146,7 @@ describe "OAuth" do
|
|
145
146
|
:currency => "USD",
|
146
147
|
:website => "http://example.com"
|
147
148
|
},
|
148
|
-
:payment_methods => ["credit_card", "paypal"]
|
149
|
+
:payment_methods => ["credit_card", "paypal"],
|
149
150
|
)
|
150
151
|
|
151
152
|
uri = URI.parse(url)
|
@@ -159,6 +160,7 @@ describe "OAuth" do
|
|
159
160
|
query["scope"].should == ["read_write"]
|
160
161
|
query["state"].should == ["baz_state"]
|
161
162
|
query["landing_page"].should == ["signup"]
|
163
|
+
query["login_only"].should == ["false"]
|
162
164
|
|
163
165
|
query["user[country]"].should == ["USA"]
|
164
166
|
query["business[name]"].should == ["14 Ladders"]
|
@@ -191,9 +193,6 @@ describe "OAuth" do
|
|
191
193
|
query["business[fulfillment_completed_in]"].should == ["7"]
|
192
194
|
query["business[currency]"].should == ["USD"]
|
193
195
|
query["business[website]"].should == ["http://example.com"]
|
194
|
-
|
195
|
-
query["signature"][0].length.should == 64
|
196
|
-
query["algorithm"].should == ["SHA256"]
|
197
196
|
end
|
198
197
|
|
199
198
|
it "builds the query string with multiple payment_methods" do
|
@@ -202,7 +201,7 @@ describe "OAuth" do
|
|
202
201
|
:redirect_uri => "http://bar.example.com",
|
203
202
|
:scope => "read_write",
|
204
203
|
:state => "baz_state",
|
205
|
-
:payment_methods => ["credit_card", "paypal"]
|
204
|
+
:payment_methods => ["credit_card", "paypal"],
|
206
205
|
)
|
207
206
|
|
208
207
|
uri = URI.parse(url)
|
@@ -214,19 +213,13 @@ describe "OAuth" do
|
|
214
213
|
query["payment_methods[]"].should include("paypal")
|
215
214
|
query["payment_methods[]"].should include("credit_card")
|
216
215
|
end
|
217
|
-
end
|
218
216
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
:client_secret => "client_secret$development$integration_client_secret",
|
224
|
-
:logger => Logger.new("/dev/null")
|
225
|
-
)
|
226
|
-
url = "http://localhost:3000/oauth/connect?business%5Bname%5D=We+Like+Spaces&client_id=client_id%24development%24integration_client_id"
|
227
|
-
signature = @gateway.oauth._compute_signature(url)
|
217
|
+
it "doesn't mutate the options" do
|
218
|
+
params = {:payment_methods => ["credit_card"]}
|
219
|
+
|
220
|
+
@gateway.oauth.connect_url(params)
|
228
221
|
|
229
|
-
|
222
|
+
params.should == {:payment_methods => ["credit_card"]}
|
230
223
|
end
|
231
224
|
end
|
232
225
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
require "date"
|
3
4
|
|
4
5
|
describe Braintree::PaymentMethodNonce do
|
5
6
|
let(:config) { Braintree::Configuration.instantiate }
|
@@ -12,12 +13,12 @@ describe Braintree::PaymentMethodNonce do
|
|
12
13
|
:number => "4111111111111111",
|
13
14
|
:expiration_month => "11",
|
14
15
|
:expiration_year => "2099",
|
15
|
-
}
|
16
|
+
},
|
16
17
|
)
|
17
18
|
|
18
19
|
result = Braintree::PaymentMethod.create(
|
19
20
|
:payment_method_nonce => nonce,
|
20
|
-
:customer_id => customer.id
|
21
|
+
:customer_id => customer.id,
|
21
22
|
)
|
22
23
|
|
23
24
|
result.should be_success
|
@@ -32,6 +33,7 @@ describe Braintree::PaymentMethodNonce do
|
|
32
33
|
result.payment_method_nonce.should_not be_nil
|
33
34
|
result.payment_method_nonce.nonce.should_not be_nil
|
34
35
|
result.payment_method_nonce.details.should_not be_nil
|
36
|
+
result.payment_method_nonce.default?.should be_truthy
|
35
37
|
end
|
36
38
|
|
37
39
|
it "correctly raises and exception for a non existent token" do
|
@@ -41,6 +43,36 @@ describe Braintree::PaymentMethodNonce do
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
46
|
+
describe "self.create!" do
|
47
|
+
it "creates a payment method nonce from a vaulted credit card" do
|
48
|
+
customer = Braintree::Customer.create.customer
|
49
|
+
nonce = nonce_for_new_payment_method(
|
50
|
+
:credit_card => {
|
51
|
+
:number => "4111111111111111",
|
52
|
+
:expiration_month => "11",
|
53
|
+
:expiration_year => "2099",
|
54
|
+
},
|
55
|
+
)
|
56
|
+
|
57
|
+
payment_method = Braintree::PaymentMethod.create!(
|
58
|
+
:payment_method_nonce => nonce,
|
59
|
+
:customer_id => customer.id,
|
60
|
+
)
|
61
|
+
|
62
|
+
payment_method.should be_a(Braintree::CreditCard)
|
63
|
+
token = payment_method.token
|
64
|
+
|
65
|
+
found_credit_card = Braintree::CreditCard.find(token)
|
66
|
+
found_credit_card.should_not be_nil
|
67
|
+
|
68
|
+
payment_method_nonce = Braintree::PaymentMethodNonce.create!(found_credit_card.token)
|
69
|
+
payment_method_nonce.should_not be_nil
|
70
|
+
payment_method_nonce.nonce.should_not be_nil
|
71
|
+
payment_method_nonce.details.should_not be_nil
|
72
|
+
payment_method_nonce.default?.should be_truthy
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
44
76
|
describe "self.find" do
|
45
77
|
it "finds and returns the nonce if one was found" do
|
46
78
|
result = Braintree::PaymentMethodNonce.find("fake-valid-nonce")
|
@@ -50,8 +82,24 @@ describe Braintree::PaymentMethodNonce do
|
|
50
82
|
result.should be_success
|
51
83
|
nonce.nonce.should == "fake-valid-nonce"
|
52
84
|
nonce.type.should == "CreditCard"
|
53
|
-
nonce.details.
|
54
|
-
nonce.details.
|
85
|
+
nonce.details.bin.should == "401288"
|
86
|
+
nonce.details.card_type.should == "Visa"
|
87
|
+
nonce.details.expiration_month.should == "12"
|
88
|
+
nonce.details.expiration_year.should == Date.today.next_year.year.to_s
|
89
|
+
nonce.details.is_network_tokenized?.should be_nil
|
90
|
+
nonce.details.last_two.should == "81"
|
91
|
+
nonce.details.payer_info.should be_nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it "return paypal details if details exist" do
|
95
|
+
result = Braintree::PaymentMethodNonce.find("fake-paypal-one-time-nonce")
|
96
|
+
nonce = result.payment_method_nonce
|
97
|
+
nonce.details.payer_info.billing_agreement_id.should be_nil
|
98
|
+
nonce.details.payer_info.country_code.should be_nil
|
99
|
+
nonce.details.payer_info.email.should_not be_nil
|
100
|
+
nonce.details.payer_info.first_name.should_not be_nil
|
101
|
+
nonce.details.payer_info.last_name.should_not be_nil
|
102
|
+
nonce.details.payer_info.payer_id.should_not be_nil
|
55
103
|
end
|
56
104
|
|
57
105
|
it "returns null 3ds_info if there isn't any" do
|
@@ -60,7 +108,7 @@ describe Braintree::PaymentMethodNonce do
|
|
60
108
|
:number => "4111111111111111",
|
61
109
|
:expiration_month => "11",
|
62
110
|
:expiration_year => "2099",
|
63
|
-
}
|
111
|
+
},
|
64
112
|
)
|
65
113
|
|
66
114
|
result = Braintree::PaymentMethodNonce.find(nonce)
|
@@ -71,10 +119,196 @@ describe Braintree::PaymentMethodNonce do
|
|
71
119
|
nonce.three_d_secure_info.should be_nil
|
72
120
|
end
|
73
121
|
|
122
|
+
it "returns the bin" do
|
123
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-visa-nonce")
|
124
|
+
|
125
|
+
nonce = result.payment_method_nonce
|
126
|
+
result.should be_success
|
127
|
+
nonce.details.should_not be_nil
|
128
|
+
nonce.details.bin.should == "401288"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns bin_data with commercial set to Yes" do
|
132
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-commercial-nonce")
|
133
|
+
|
134
|
+
nonce = result.payment_method_nonce
|
135
|
+
|
136
|
+
result.should be_success
|
137
|
+
nonce.bin_data.should_not be_nil
|
138
|
+
nonce.bin_data.commercial.should == Braintree::CreditCard::Commercial::Yes
|
139
|
+
end
|
140
|
+
|
141
|
+
it "returns bin_data with country_of_issuance set to CAN" do
|
142
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-country-of-issuance-cad-nonce")
|
143
|
+
|
144
|
+
nonce = result.payment_method_nonce
|
145
|
+
|
146
|
+
result.should be_success
|
147
|
+
nonce.bin_data.should_not be_nil
|
148
|
+
nonce.bin_data.country_of_issuance.should == "CAN"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "returns bin_data with debit set to Yes" do
|
152
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-debit-nonce")
|
153
|
+
|
154
|
+
nonce = result.payment_method_nonce
|
155
|
+
|
156
|
+
result.should be_success
|
157
|
+
nonce.bin_data.should_not be_nil
|
158
|
+
nonce.bin_data.debit.should == Braintree::CreditCard::Debit::Yes
|
159
|
+
end
|
160
|
+
|
161
|
+
it "returns bin_data with durbin_regulated set to Yes" do
|
162
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-durbin-regulated-nonce")
|
163
|
+
|
164
|
+
nonce = result.payment_method_nonce
|
165
|
+
|
166
|
+
result.should be_success
|
167
|
+
nonce.bin_data.should_not be_nil
|
168
|
+
nonce.bin_data.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
|
169
|
+
end
|
170
|
+
|
171
|
+
it "returns bin_data with healthcare set to Yes" do
|
172
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-healthcare-nonce")
|
173
|
+
|
174
|
+
nonce = result.payment_method_nonce
|
175
|
+
|
176
|
+
result.should be_success
|
177
|
+
nonce.bin_data.should_not be_nil
|
178
|
+
nonce.bin_data.healthcare.should == Braintree::CreditCard::Healthcare::Yes
|
179
|
+
nonce.bin_data.product_id.should == "J3"
|
180
|
+
end
|
181
|
+
|
182
|
+
it "returns bin_data with issuing_bank set to Network Only" do
|
183
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-issuing-bank-network-only-nonce")
|
184
|
+
|
185
|
+
nonce = result.payment_method_nonce
|
186
|
+
|
187
|
+
result.should be_success
|
188
|
+
nonce.bin_data.should_not be_nil
|
189
|
+
nonce.bin_data.issuing_bank.should == "NETWORK ONLY"
|
190
|
+
end
|
191
|
+
|
192
|
+
it "returns bin_data with payroll set to Yes" do
|
193
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-payroll-nonce")
|
194
|
+
|
195
|
+
nonce = result.payment_method_nonce
|
196
|
+
|
197
|
+
result.should be_success
|
198
|
+
nonce.bin_data.should_not be_nil
|
199
|
+
nonce.bin_data.payroll.should == Braintree::CreditCard::Payroll::Yes
|
200
|
+
nonce.bin_data.product_id.should == "MSA"
|
201
|
+
end
|
202
|
+
|
203
|
+
it "returns bin_data with prepaid set to Yes" do
|
204
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-prepaid-nonce")
|
205
|
+
|
206
|
+
nonce = result.payment_method_nonce
|
207
|
+
|
208
|
+
result.should be_success
|
209
|
+
nonce.bin_data.should_not be_nil
|
210
|
+
nonce.bin_data.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
211
|
+
end
|
212
|
+
|
213
|
+
it "returns bin_data with unknown indicators" do
|
214
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-unknown-indicators-nonce")
|
215
|
+
|
216
|
+
nonce = result.payment_method_nonce
|
217
|
+
|
218
|
+
result.should be_success
|
219
|
+
nonce.bin_data.should_not be_nil
|
220
|
+
nonce.bin_data.commercial.should == Braintree::CreditCard::Commercial::Unknown
|
221
|
+
nonce.bin_data.country_of_issuance.should == Braintree::CreditCard::CountryOfIssuance::Unknown
|
222
|
+
nonce.bin_data.debit.should == Braintree::CreditCard::Debit::Unknown
|
223
|
+
nonce.bin_data.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Unknown
|
224
|
+
nonce.bin_data.healthcare.should == Braintree::CreditCard::Healthcare::Unknown
|
225
|
+
nonce.bin_data.issuing_bank.should == Braintree::CreditCard::IssuingBank::Unknown
|
226
|
+
nonce.bin_data.payroll.should == Braintree::CreditCard::Payroll::Unknown
|
227
|
+
nonce.bin_data.prepaid.should == Braintree::CreditCard::Prepaid::Unknown
|
228
|
+
nonce.bin_data.product_id.should == Braintree::CreditCard::ProductId::Unknown
|
229
|
+
end
|
230
|
+
|
74
231
|
it "correctly raises and exception for a non existent token" do
|
75
232
|
expect do
|
76
233
|
Braintree::PaymentMethodNonce.find("not_a_nonce")
|
77
234
|
end.to raise_error(Braintree::NotFoundError)
|
78
235
|
end
|
236
|
+
|
237
|
+
context "authentication insights" do
|
238
|
+
let(:indian_payment_token) { "india_visa_credit" }
|
239
|
+
let(:european_payment_token) { "european_visa_credit" }
|
240
|
+
let(:indian_merchant_token) { "india_three_d_secure_merchant_account" }
|
241
|
+
let(:european_merchant_token) { "european_three_d_secure_merchant_account" }
|
242
|
+
|
243
|
+
describe "self.create" do
|
244
|
+
it "raises an exception if hash includes an invalid key" do
|
245
|
+
expect do
|
246
|
+
Braintree::PaymentMethodNonce.create("european_visa_credit", :invalid_key => "foo")
|
247
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context "regulation environments" do
|
252
|
+
it "can get unregulated" do
|
253
|
+
expect(
|
254
|
+
request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment],
|
255
|
+
).to eq "unregulated"
|
256
|
+
end
|
257
|
+
|
258
|
+
it "can get psd2" do
|
259
|
+
expect(
|
260
|
+
request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment],
|
261
|
+
).to eq "psd2"
|
262
|
+
end
|
263
|
+
|
264
|
+
it "can get rbi" do
|
265
|
+
expect(
|
266
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment],
|
267
|
+
).to eq "rbi"
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context "sca_indicator" do
|
272
|
+
it "can get unavailable" do
|
273
|
+
expect(
|
274
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator],
|
275
|
+
).to eq "unavailable"
|
276
|
+
end
|
277
|
+
|
278
|
+
it "can get sca_required" do
|
279
|
+
expect(
|
280
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator],
|
281
|
+
).to eq "sca_required"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "can get sca_optional" do
|
285
|
+
expect(
|
286
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator],
|
287
|
+
|
288
|
+
).to eq "sca_optional"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def request_authentication_insights(merchant_token, payment_method_token, options = {})
|
293
|
+
authentication_insight_options = {
|
294
|
+
amount: options[:amount],
|
295
|
+
recurring_customer_consent: options[:recurring_customer_consent],
|
296
|
+
recurring_max_amount: options[:recurring_max_amount],
|
297
|
+
}
|
298
|
+
nonce_request = {
|
299
|
+
merchant_account_id: merchant_token,
|
300
|
+
authentication_insight: true,
|
301
|
+
authentication_insight_options: authentication_insight_options,
|
302
|
+
}
|
303
|
+
|
304
|
+
result = Braintree::PaymentMethodNonce.create(
|
305
|
+
payment_method_token,
|
306
|
+
payment_method_nonce: nonce_request,
|
307
|
+
)
|
308
|
+
result.should be_success
|
309
|
+
|
310
|
+
return result.payment_method_nonce.authentication_insight
|
311
|
+
end
|
312
|
+
end
|
79
313
|
end
|
80
314
|
end
|