braintree 2.98.0 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +4 -4
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +7 -27
- data/lib/braintree/address_gateway.rb +8 -7
- data/lib/braintree/advanced_search.rb +11 -12
- data/lib/braintree/apple_pay.rb +4 -4
- data/lib/braintree/apple_pay_card.rb +18 -4
- data/lib/braintree/apple_pay_options.rb +4 -4
- data/lib/braintree/authorization_adjustment.rb +4 -4
- data/lib/braintree/base_module.rb +11 -1
- data/lib/braintree/bin_data.rb +10 -3
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/client_token_gateway.rb +4 -3
- data/lib/braintree/configuration.rb +35 -35
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
- data/lib/braintree/credit_card.rb +40 -86
- data/lib/braintree/credit_card_gateway.rb +58 -44
- data/lib/braintree/credit_card_verification.rb +39 -20
- data/lib/braintree/credit_card_verification_gateway.rb +35 -5
- data/lib/braintree/credit_card_verification_search.rb +2 -2
- data/lib/braintree/customer.rb +23 -88
- data/lib/braintree/customer_gateway.rb +17 -32
- data/lib/braintree/customer_search.rb +2 -2
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +7 -7
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute/transaction.rb +3 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +47 -6
- data/lib/braintree/dispute_gateway.rb +5 -10
- data/lib/braintree/dispute_search.rb +8 -4
- data/lib/braintree/document_upload.rb +3 -3
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +217 -175
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +6 -5
- 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 +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/gateway.rb +6 -12
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
- data/lib/braintree/granted_payment_instrument_update.rb +2 -2
- data/lib/braintree/graphql_client.rb +14 -8
- data/lib/braintree/http.rb +9 -10
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +10 -5
- 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 +4 -4
- data/lib/braintree/merchant_account.rb +3 -3
- data/lib/braintree/merchant_account_gateway.rb +10 -8
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +4 -4
- data/lib/braintree/oauth_credentials.rb +4 -4
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +14 -13
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +52 -22
- data/lib/braintree/payment_method_nonce.rb +12 -7
- 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 +14 -3
- data/lib/braintree/payment_method_parser.rb +4 -7
- data/lib/braintree/paypal_account.rb +3 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +22 -2
- data/lib/braintree/plan_gateway.rb +101 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +10 -5
- data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +10 -3
- data/lib/braintree/samsung_pay_card.rb +8 -6
- 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 -2
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +13 -13
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +5 -4
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +9 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +27 -20
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +23 -11
- data/lib/braintree/transaction/address_details.rb +14 -1
- data/lib/braintree/transaction/apple_pay_details.rb +13 -10
- data/lib/braintree/transaction/credit_card_details.rb +8 -1
- data/lib/braintree/transaction/customer_details.rb +3 -2
- data/lib/braintree/transaction/disbursement_details.rb +2 -1
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
- 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 +3 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/package_details.rb +19 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/paypal_details.rb +5 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +3 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +119 -128
- data/lib/braintree/transaction_gateway.rb +138 -64
- data/lib/braintree/transaction_line_item.rb +14 -11
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +11 -7
- data/lib/braintree/unknown_payment_method.rb +2 -2
- data/lib/braintree/us_bank_account.rb +5 -5
- data/lib/braintree/us_bank_account_verification.rb +24 -16
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +25 -10
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +4 -4
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +8 -8
- data/lib/braintree/webhook_notification.rb +55 -33
- data/lib/braintree/webhook_notification_gateway.rb +9 -9
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +569 -46
- data/lib/braintree/xml/generator.rb +6 -5
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -37
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +41 -24
- data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
- data/spec/integration/braintree/add_on_spec.rb +10 -10
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +93 -93
- data/spec/integration/braintree/apple_pay_spec.rb +12 -12
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
- data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
- data/spec/integration/braintree/credit_card_spec.rb +522 -821
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
- data/spec/integration/braintree/customer_search_spec.rb +28 -28
- data/spec/integration/braintree/customer_spec.rb +840 -757
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +45 -9
- data/spec/integration/braintree/dispute_spec.rb +109 -82
- data/spec/integration/braintree/document_upload_spec.rb +29 -17
- data/spec/integration/braintree/error_codes_spec.rb +3 -3
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +0 -2
- data/spec/integration/braintree/http_spec.rb +31 -33
- data/spec/integration/braintree/merchant_account_spec.rb +155 -156
- data/spec/integration/braintree/merchant_spec.rb +71 -192
- data/spec/integration/braintree/oauth_spec.rb +72 -72
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
- data/spec/integration/braintree/payment_method_spec.rb +953 -501
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
- data/spec/integration/braintree/paypal_account_spec.rb +74 -72
- data/spec/integration/braintree/plan_spec.rb +96 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
- data/spec/integration/braintree/subscription_spec.rb +507 -513
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +29 -29
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +410 -217
- data/spec/integration/braintree/transaction_spec.rb +3252 -2102
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
- data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
- data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
- data/spec/integration/spec_helper.rb +22 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +15 -20
- data/spec/unit/braintree/address_spec.rb +9 -17
- data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +6 -6
- data/spec/unit/braintree/configuration_spec.rb +84 -84
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +91 -58
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
- data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
- data/spec/unit/braintree/customer_spec.rb +102 -57
- data/spec/unit/braintree/digest_spec.rb +5 -6
- data/spec/unit/braintree/disbursement_spec.rb +14 -14
- data/spec/unit/braintree/dispute_search_spec.rb +6 -2
- data/spec/unit/braintree/dispute_spec.rb +144 -66
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
- data/spec/unit/braintree/error_result_spec.rb +11 -11
- data/spec/unit/braintree/errors_spec.rb +17 -17
- 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 +19 -17
- data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
- 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 +5 -5
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +77 -0
- 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 +20 -20
- data/spec/unit/braintree/paypal_account_spec.rb +16 -7
- data/spec/unit/braintree/resource_collection_spec.rb +34 -5
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +38 -8
- 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/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +18 -18
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +6 -6
- data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -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 +150 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +221 -124
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
- data/spec/unit/braintree/util_spec.rb +78 -44
- data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +434 -197
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +27 -22
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +38 -38
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +91 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -81
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
- 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/integration/braintree/coinbase_spec.rb +0 -34
- 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
@@ -12,12 +12,40 @@ describe Braintree::ClientToken do
|
|
12
12
|
config,
|
13
13
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
14
14
|
:shared_customer_identifier => "fake_identifier",
|
15
|
-
:shared_customer_identifier_type => "testing"
|
15
|
+
:shared_customer_identifier_type => "testing",
|
16
16
|
)
|
17
17
|
|
18
18
|
response = http.get_payment_methods
|
19
19
|
|
20
|
-
response.code.
|
20
|
+
expect(response.code).to eq("200")
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "domains" do
|
24
|
+
it "allows a domain to be specified" do
|
25
|
+
client_token_string = Braintree::ClientToken.generate(:domains => ["example.com"])
|
26
|
+
client_token = decode_client_token(client_token_string)
|
27
|
+
authorization_fingerprint = Base64.decode64(client_token["authorizationFingerprint"])
|
28
|
+
expect(authorization_fingerprint.include? "example.com").to eq(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises ClientTokenTooManyDomains on too many domains" do
|
32
|
+
expect do
|
33
|
+
Braintree::ClientToken.generate(
|
34
|
+
:domains => ["example1.com",
|
35
|
+
"example2.com",
|
36
|
+
"example3.com",
|
37
|
+
"example4.com",
|
38
|
+
"example5.com",
|
39
|
+
"example6.com"
|
40
|
+
])
|
41
|
+
end.to raise_error(ArgumentError, "Cannot specify more than 5 client token domains")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "raises ClientTokenInvalidDomainFormat on invalid format" do
|
45
|
+
expect do
|
46
|
+
Braintree::ClientToken.generate(:domains => ["example"])
|
47
|
+
end.to raise_error(ArgumentError, "Client token domains must be valid domain names (RFC 1035), e.g. example.com")
|
48
|
+
end
|
21
49
|
end
|
22
50
|
|
23
51
|
it "raises ArgumentError on invalid parameters (422)" do
|
@@ -28,17 +56,15 @@ describe Braintree::ClientToken do
|
|
28
56
|
|
29
57
|
describe "version" do
|
30
58
|
it "allows a client token version to be specified" do
|
31
|
-
config = Braintree::Configuration.instantiate
|
32
59
|
client_token_string = Braintree::ClientToken.generate(:version => 1)
|
33
60
|
client_token = JSON.parse(client_token_string)
|
34
|
-
client_token["version"].
|
61
|
+
expect(client_token["version"]).to eq(1)
|
35
62
|
end
|
36
63
|
|
37
64
|
it "defaults to 2" do
|
38
|
-
config = Braintree::Configuration.instantiate
|
39
65
|
client_token_string = Braintree::ClientToken.generate
|
40
66
|
client_token = decode_client_token(client_token_string)
|
41
|
-
client_token["version"].
|
67
|
+
expect(client_token["version"]).to eq(2)
|
42
68
|
end
|
43
69
|
end
|
44
70
|
|
@@ -49,7 +75,7 @@ describe Braintree::ClientToken do
|
|
49
75
|
:customer_id => result.customer.id,
|
50
76
|
:options => {
|
51
77
|
:verify_card => true
|
52
|
-
}
|
78
|
+
},
|
53
79
|
)
|
54
80
|
client_token = decode_client_token(raw_client_token)
|
55
81
|
|
@@ -57,7 +83,7 @@ describe Braintree::ClientToken do
|
|
57
83
|
config,
|
58
84
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
59
85
|
:shared_customer_identifier => "fake_identifier",
|
60
|
-
:shared_customer_identifier_type => "testing"
|
86
|
+
:shared_customer_identifier_type => "testing",
|
61
87
|
)
|
62
88
|
|
63
89
|
response = http.add_payment_method(
|
@@ -65,10 +91,10 @@ describe Braintree::ClientToken do
|
|
65
91
|
:number => "4000111111111115",
|
66
92
|
:expiration_month => "11",
|
67
93
|
:expiration_year => "2099"
|
68
|
-
}
|
94
|
+
},
|
69
95
|
)
|
70
96
|
|
71
|
-
response.code.
|
97
|
+
expect(response.code).to eq("422")
|
72
98
|
end
|
73
99
|
|
74
100
|
it "can pass make_default" do
|
@@ -79,7 +105,7 @@ describe Braintree::ClientToken do
|
|
79
105
|
:customer_id => customer_id,
|
80
106
|
:options => {
|
81
107
|
:make_default => true
|
82
|
-
}
|
108
|
+
},
|
83
109
|
)
|
84
110
|
client_token = decode_client_token(raw_client_token)
|
85
111
|
|
@@ -87,7 +113,7 @@ describe Braintree::ClientToken do
|
|
87
113
|
config,
|
88
114
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
89
115
|
:shared_customer_identifier => "fake_identifier",
|
90
|
-
:shared_customer_identifier_type => "testing"
|
116
|
+
:shared_customer_identifier_type => "testing",
|
91
117
|
)
|
92
118
|
|
93
119
|
response = http.add_payment_method(
|
@@ -95,81 +121,272 @@ describe Braintree::ClientToken do
|
|
95
121
|
:number => "4111111111111111",
|
96
122
|
:expiration_month => "11",
|
97
123
|
:expiration_year => "2099"
|
98
|
-
}
|
124
|
+
},
|
99
125
|
)
|
100
126
|
|
101
|
-
response.code.
|
127
|
+
expect(response.code).to eq("201")
|
102
128
|
|
103
129
|
response = http.add_payment_method(
|
104
130
|
:credit_card => {
|
105
131
|
:number => "4005519200000004",
|
106
132
|
:expiration_month => "11",
|
107
133
|
:expiration_year => "2099"
|
108
|
-
}
|
134
|
+
},
|
109
135
|
)
|
110
136
|
|
111
|
-
response.code.
|
137
|
+
expect(response.code).to eq("201")
|
112
138
|
|
113
139
|
customer = Braintree::Customer.find(customer_id)
|
114
|
-
customer.credit_cards.select { |c| c.bin == "400551" }[0].
|
140
|
+
expect(customer.credit_cards.select { |c| c.bin == "400551" }[0]).to be_default
|
115
141
|
end
|
116
142
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
143
|
+
context "fail on duplicate payment methods check" do
|
144
|
+
context "card exists for a different customer" do
|
145
|
+
before(:each) do
|
146
|
+
config = Braintree::Configuration.instantiate
|
147
|
+
result = Braintree::Customer.create
|
148
|
+
customer_id = result.customer.id
|
149
|
+
raw_client_token = Braintree::ClientToken.generate(
|
150
|
+
:customer_id => customer_id,
|
151
|
+
)
|
152
|
+
client_token = decode_client_token(raw_client_token)
|
125
153
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
154
|
+
http = ClientApiHttp.new(
|
155
|
+
config,
|
156
|
+
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
157
|
+
:shared_customer_identifier => "fake_identifier",
|
158
|
+
:shared_customer_identifier_type => "testing",
|
159
|
+
)
|
132
160
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
161
|
+
response = http.add_payment_method(
|
162
|
+
:credit_card => {
|
163
|
+
:number => "4111111111111111",
|
164
|
+
:expiration_month => "11",
|
165
|
+
:expiration_year => "2099"
|
166
|
+
},
|
167
|
+
)
|
168
|
+
expect(response.code).to eq("201")
|
169
|
+
end
|
140
170
|
|
141
|
-
|
171
|
+
it "does not create when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = false" do
|
172
|
+
result = Braintree::Customer.create
|
173
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
174
|
+
:customer_id => result.customer_id,
|
175
|
+
:options => {
|
176
|
+
:fail_on_duplicate_payment_method => true,
|
177
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
178
|
+
},
|
179
|
+
)
|
180
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
142
181
|
|
143
|
-
|
144
|
-
:customer_id => customer_id,
|
145
|
-
:options => {
|
146
|
-
:fail_on_duplicate_payment_method => true
|
147
|
-
}
|
148
|
-
)
|
149
|
-
second_client_token = decode_client_token(second_raw_client_token)
|
182
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
150
183
|
|
151
|
-
|
184
|
+
response = http.add_payment_method(
|
185
|
+
:credit_card => {
|
186
|
+
:number => "4111111111111111",
|
187
|
+
:expiration_month => "11",
|
188
|
+
:expiration_year => "2099"
|
189
|
+
},
|
190
|
+
)
|
191
|
+
expect(response.code).to eq("201")
|
192
|
+
end
|
152
193
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
194
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = true" do
|
195
|
+
result = Braintree::Customer.create
|
196
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
197
|
+
:customer_id => result.customer_id,
|
198
|
+
:options => {
|
199
|
+
:fail_on_duplicate_payment_method => true,
|
200
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
201
|
+
},
|
202
|
+
)
|
203
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
204
|
+
|
205
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
206
|
+
|
207
|
+
response = http.add_payment_method(
|
208
|
+
:credit_card => {
|
209
|
+
:number => "4111111111111111",
|
210
|
+
:expiration_month => "11",
|
211
|
+
:expiration_year => "2099"
|
212
|
+
},
|
213
|
+
)
|
214
|
+
expect(response.code).to eq("201")
|
215
|
+
end
|
216
|
+
|
217
|
+
it "does not create fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = true" do
|
218
|
+
result = Braintree::Customer.create
|
219
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
220
|
+
:customer_id => result.customer_id,
|
221
|
+
:options => {
|
222
|
+
:fail_on_duplicate_payment_method => true,
|
223
|
+
:fail_on_duplicate_payment_method_for_customer => true
|
224
|
+
},
|
225
|
+
)
|
226
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
227
|
+
|
228
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
229
|
+
|
230
|
+
response = http.add_payment_method(
|
231
|
+
:credit_card => {
|
232
|
+
:number => "4111111111111111",
|
233
|
+
:expiration_month => "11",
|
234
|
+
:expiration_year => "2099"
|
235
|
+
},
|
236
|
+
)
|
237
|
+
expect(response.code).to eq("422")
|
238
|
+
end
|
160
239
|
|
161
|
-
|
240
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = false" do
|
241
|
+
result = Braintree::Customer.create
|
242
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
243
|
+
:customer_id => result.customer_id,
|
244
|
+
:options => {
|
245
|
+
:fail_on_duplicate_payment_method => false,
|
246
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
247
|
+
},
|
248
|
+
)
|
249
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
250
|
+
|
251
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
252
|
+
|
253
|
+
response = http.add_payment_method(
|
254
|
+
:credit_card => {
|
255
|
+
:number => "4111111111111111",
|
256
|
+
:expiration_month => "11",
|
257
|
+
:expiration_year => "2099"
|
258
|
+
},
|
259
|
+
)
|
260
|
+
expect(response.code).to eq("201")
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context "card exists for a same customer" do
|
265
|
+
before(:each) do
|
266
|
+
config = Braintree::Configuration.instantiate
|
267
|
+
result = Braintree::Customer.create
|
268
|
+
let(:customer_id) { result.customer.id }
|
269
|
+
raw_client_token = Braintree::ClientToken.generate(
|
270
|
+
:customer_id => customer_id,
|
271
|
+
)
|
272
|
+
client_token = decode_client_token(raw_client_token)
|
273
|
+
|
274
|
+
http = ClientApiHttp.new(
|
275
|
+
config,
|
276
|
+
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
277
|
+
:shared_customer_identifier => "fake_identifier",
|
278
|
+
:shared_customer_identifier_type => "testing",
|
279
|
+
)
|
280
|
+
|
281
|
+
response = http.add_payment_method(
|
282
|
+
:credit_card => {
|
283
|
+
:number => "4111111111111111",
|
284
|
+
:expiration_month => "11",
|
285
|
+
:expiration_year => "2099"
|
286
|
+
},
|
287
|
+
)
|
288
|
+
expect(response.code).to eq("201")
|
289
|
+
end
|
290
|
+
|
291
|
+
it "creates when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = false for same customer" do
|
292
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
293
|
+
:customer_id => customer_id,
|
294
|
+
:options => {
|
295
|
+
:fail_on_duplicate_payment_method => true,
|
296
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
297
|
+
},
|
298
|
+
)
|
299
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
300
|
+
|
301
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
302
|
+
|
303
|
+
response = http.add_payment_method(
|
304
|
+
:credit_card => {
|
305
|
+
:number => "4111111111111111",
|
306
|
+
:expiration_month => "11",
|
307
|
+
:expiration_year => "2099"
|
308
|
+
},
|
309
|
+
)
|
310
|
+
expect(response.code).to eq("201")
|
311
|
+
end
|
312
|
+
|
313
|
+
it "does not create when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = true for same customer" do
|
314
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
315
|
+
:customer_id => customer_id,
|
316
|
+
:options => {
|
317
|
+
:fail_on_duplicate_payment_method => false,
|
318
|
+
:fail_on_duplicate_payment_method_for_customer => true
|
319
|
+
},
|
320
|
+
)
|
321
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
322
|
+
|
323
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
324
|
+
|
325
|
+
response = http.add_payment_method(
|
326
|
+
:credit_card => {
|
327
|
+
:number => "4111111111111111",
|
328
|
+
:expiration_month => "11",
|
329
|
+
:expiration_year => "2099"
|
330
|
+
},
|
331
|
+
)
|
332
|
+
expect(response.code).to eq("422")
|
333
|
+
end
|
334
|
+
|
335
|
+
it "does not create when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = true for same customer" do
|
336
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
337
|
+
:customer_id => customer_id,
|
338
|
+
:options => {
|
339
|
+
:fail_on_duplicate_payment_method => true,
|
340
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
341
|
+
},
|
342
|
+
)
|
343
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
344
|
+
|
345
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
346
|
+
|
347
|
+
response = http.add_payment_method(
|
348
|
+
:credit_card => {
|
349
|
+
:number => "4111111111111111",
|
350
|
+
:expiration_month => "11",
|
351
|
+
:expiration_year => "2099"
|
352
|
+
},
|
353
|
+
)
|
354
|
+
expect(response.code).to eq("422")
|
355
|
+
end
|
356
|
+
|
357
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = false for same customer" do
|
358
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
359
|
+
:customer_id => customer_id,
|
360
|
+
:options => {
|
361
|
+
:fail_on_duplicate_payment_method => false,
|
362
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
363
|
+
},
|
364
|
+
)
|
365
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
366
|
+
|
367
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
368
|
+
|
369
|
+
response = http.add_payment_method(
|
370
|
+
:credit_card => {
|
371
|
+
:number => "4111111111111111",
|
372
|
+
:expiration_month => "11",
|
373
|
+
:expiration_year => "2099"
|
374
|
+
},
|
375
|
+
)
|
376
|
+
expect(response.code).to eq("201")
|
377
|
+
end
|
378
|
+
end
|
162
379
|
end
|
163
380
|
|
164
381
|
it "can pass merchant_account_id" do
|
165
382
|
merchant_account_id = SpecHelper::NonDefaultMerchantAccountId
|
166
383
|
|
167
384
|
raw_client_token = Braintree::ClientToken.generate(
|
168
|
-
:merchant_account_id => merchant_account_id
|
385
|
+
:merchant_account_id => merchant_account_id,
|
169
386
|
)
|
170
387
|
client_token = decode_client_token(raw_client_token)
|
171
388
|
|
172
|
-
client_token["merchantAccountId"].
|
389
|
+
expect(client_token["merchantAccountId"]).to eq(merchant_account_id)
|
173
390
|
end
|
174
391
|
|
175
392
|
context "paypal" do
|
@@ -178,11 +395,11 @@ describe Braintree::ClientToken do
|
|
178
395
|
raw_client_token = Braintree::ClientToken.generate
|
179
396
|
client_token = decode_client_token(raw_client_token)
|
180
397
|
|
181
|
-
client_token["paypal"]["displayName"].
|
182
|
-
client_token["paypal"]["clientId"].
|
183
|
-
client_token["paypal"]["privacyUrl"].
|
184
|
-
client_token["paypal"]["userAgreementUrl"].
|
185
|
-
client_token["paypal"]["baseUrl"].
|
398
|
+
expect(client_token["paypal"]["displayName"]).to eq("merchant who has paypal and sepa enabled")
|
399
|
+
expect(client_token["paypal"]["clientId"]).to match(/.+/)
|
400
|
+
expect(client_token["paypal"]["privacyUrl"]).to match("http://www.example.com/privacy_policy")
|
401
|
+
expect(client_token["paypal"]["userAgreementUrl"]).to match("http://www.example.com/user_agreement")
|
402
|
+
expect(client_token["paypal"]["baseUrl"]).not_to be_nil
|
186
403
|
end
|
187
404
|
end
|
188
405
|
end
|