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
@@ -1,223 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
describe Braintree::TransparentRedirect do
|
4
|
-
describe "self.create_credit_card_data" do
|
5
|
-
it "raises an exception if any keys are invalid" do
|
6
|
-
expect do
|
7
|
-
Braintree::TransparentRedirect.create_credit_card_data(
|
8
|
-
:credit_card => {:number => "ok", :invalid_key => "bad"}
|
9
|
-
)
|
10
|
-
end.to raise_error(ArgumentError, "invalid keys: credit_card[invalid_key]")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "self.create_customer_data" do
|
15
|
-
it "raises an exception if any keys are invalid" do
|
16
|
-
expect do
|
17
|
-
Braintree::TransparentRedirect.create_customer_data(
|
18
|
-
:customer => {:first_name => "ok", :invalid_key => "bad"}
|
19
|
-
)
|
20
|
-
end.to raise_error(ArgumentError, "invalid keys: customer[invalid_key]")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "self.parse_and_validate_query_string" do
|
25
|
-
it "returns the parsed query string params if the hash is valid" do
|
26
|
-
query_string_without_hash = "one=1&two=2&http_status=200"
|
27
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, query_string_without_hash)
|
28
|
-
|
29
|
-
query_string_with_hash = "#{query_string_without_hash}&hash=#{hash}"
|
30
|
-
result = Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string query_string_with_hash
|
31
|
-
result.should == {:one => "1", :two => "2", :http_status => "200", :hash => hash}
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns the parsed query string params if the hash is valid and hash is first parameter" do
|
35
|
-
query_string_without_hash = "one=1&two=2&http_status=200"
|
36
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, query_string_without_hash)
|
37
|
-
|
38
|
-
query_string_with_hash = "hash=#{hash}&#{query_string_without_hash}"
|
39
|
-
result = Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string query_string_with_hash
|
40
|
-
result.should == {:one => "1", :two => "2", :http_status => "200", :hash => hash}
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns the parsed query string params regardless of hash position if the hash is valid" do
|
44
|
-
query_string_without_hash = "one=1&two=2&http_status=200"
|
45
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, query_string_without_hash)
|
46
|
-
|
47
|
-
query_string_with_hash = "one=1&hash=#{hash}&two=2&http_status=200"
|
48
|
-
result = Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string query_string_with_hash
|
49
|
-
result.should == {:one => "1", :two => "2", :http_status => "200", :hash => hash}
|
50
|
-
end
|
51
|
-
|
52
|
-
it "raises Braintree::ForgedQueryString if the hash param is not valid" do
|
53
|
-
query_string_without_hash = "http_status=200&one=1&two=2"
|
54
|
-
hash = Digest::SHA1.hexdigest("invalid#{query_string_without_hash}")
|
55
|
-
|
56
|
-
query_string_with_hash = "#{query_string_without_hash}&hash=#{hash}"
|
57
|
-
expect do
|
58
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string query_string_with_hash
|
59
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "raises Braintree::ForgedQueryString if hash is missing from the query string" do
|
63
|
-
expect do
|
64
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string "http_status=200&query_string=without_a_hash"
|
65
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "does not raise Braintree::ForgedQueryString if query string is url encoded" do
|
69
|
-
url_encoded_query_string_without_hash = "http_status%3D200%26nested_param%5Bsub_param%5D%3Dtesting"
|
70
|
-
url_decoded_query_string_without_hash = Braintree::Util.url_decode(url_encoded_query_string_without_hash)
|
71
|
-
|
72
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, url_decoded_query_string_without_hash)
|
73
|
-
|
74
|
-
url_encoded_query_string = "#{url_encoded_query_string_without_hash}&hash=#{hash}"
|
75
|
-
|
76
|
-
expect do
|
77
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string url_encoded_query_string
|
78
|
-
end.to raise_error(Braintree::UnexpectedError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "does not raise Braintree::ForgedQueryString if query string is url decoded" do
|
82
|
-
url_decoded_query_string_without_hash = "http_status=200&nested_param[sub_param]=testing"
|
83
|
-
url_encoded_query_string_without_hash = Braintree::Util.url_encode(url_decoded_query_string_without_hash)
|
84
|
-
|
85
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, url_encoded_query_string_without_hash)
|
86
|
-
|
87
|
-
url_decoded_query_string = "#{url_decoded_query_string_without_hash}&hash=#{hash}"
|
88
|
-
|
89
|
-
expect do
|
90
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string url_decoded_query_string
|
91
|
-
end.to_not raise_error
|
92
|
-
end
|
93
|
-
|
94
|
-
it "does not raise Braintree::ForgedQueryString if the query string is partially encoded" do
|
95
|
-
url_partially_encoded_query_string_without_hash = "http_status=200&nested_param%5Bsub_param%5D=testing"
|
96
|
-
|
97
|
-
hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, url_partially_encoded_query_string_without_hash)
|
98
|
-
|
99
|
-
url_partially_encoded_query_string = "#{url_partially_encoded_query_string_without_hash}&hash=#{hash}"
|
100
|
-
|
101
|
-
expect do
|
102
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string url_partially_encoded_query_string
|
103
|
-
end.to_not raise_error
|
104
|
-
end
|
105
|
-
|
106
|
-
it "raises an AuthenticationError if authentication fails" do
|
107
|
-
expect do
|
108
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=401")
|
109
|
-
end.to raise_error(Braintree::AuthenticationError)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "raises an AuthorizationError if authorization fails" do
|
113
|
-
expect do
|
114
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=403")
|
115
|
-
end.to raise_error(Braintree::AuthorizationError)
|
116
|
-
end
|
117
|
-
|
118
|
-
it "raises an UnexpectedError if http_status is not in query string" do
|
119
|
-
expect do
|
120
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("no_http_status=x")
|
121
|
-
end.to raise_error(Braintree::UnexpectedError, "expected query string to have an http_status param")
|
122
|
-
end
|
123
|
-
|
124
|
-
it "raises a ServerError if the server 500's" do
|
125
|
-
expect do
|
126
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=500")
|
127
|
-
end.to raise_error(Braintree::ServerError)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "raises a DownForMaintenanceError if the server is down for maintenance" do
|
131
|
-
expect do
|
132
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=503")
|
133
|
-
end.to raise_error(Braintree::DownForMaintenanceError)
|
134
|
-
end
|
135
|
-
|
136
|
-
it "raises an UnexpectedError if some other code is returned" do
|
137
|
-
expect do
|
138
|
-
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=600")
|
139
|
-
end.to raise_error(Braintree::UnexpectedError, "Unexpected HTTP_RESPONSE 600")
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "self.transaction_data" do
|
144
|
-
it "raises an exception if any keys are invalid" do
|
145
|
-
expect do
|
146
|
-
Braintree::TransparentRedirect.transaction_data(
|
147
|
-
:transaction => {:amount => "100.00", :invalid_key => "bad"}
|
148
|
-
)
|
149
|
-
end.to raise_error(ArgumentError, "invalid keys: transaction[invalid_key]")
|
150
|
-
end
|
151
|
-
|
152
|
-
it "raises an exception if not given a type" do
|
153
|
-
expect do
|
154
|
-
Braintree::TransparentRedirect.transaction_data(
|
155
|
-
:redirect_url => "http://example.com",
|
156
|
-
:transaction => {:amount => "100.00"}
|
157
|
-
)
|
158
|
-
end.to raise_error(ArgumentError, "expected transaction[type] of sale or credit, was: nil")
|
159
|
-
end
|
160
|
-
|
161
|
-
it "raises an exception if not given a type of sale or credit" do
|
162
|
-
expect do
|
163
|
-
Braintree::TransparentRedirect.transaction_data(
|
164
|
-
:redirect_url => "http://example.com",
|
165
|
-
:transaction => {:amount => "100.00", :type => "auth"}
|
166
|
-
)
|
167
|
-
end.to raise_error(ArgumentError, "expected transaction[type] of sale or credit, was: \"auth\"")
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "self.update_credit_card_data" do
|
172
|
-
it "raises an exception if any keys are invalid" do
|
173
|
-
expect do
|
174
|
-
Braintree::TransparentRedirect.update_credit_card_data(
|
175
|
-
:credit_card => {:number => "ok", :invalid_key => "bad"}
|
176
|
-
)
|
177
|
-
end.to raise_error(ArgumentError, "invalid keys: credit_card[invalid_key]")
|
178
|
-
end
|
179
|
-
|
180
|
-
it "raises an exception if not given a payment_method_token" do
|
181
|
-
expect do
|
182
|
-
Braintree::TransparentRedirect.update_credit_card_data({})
|
183
|
-
end.to raise_error(ArgumentError, "expected params to contain :payment_method_token of payment method to update")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "self.update_customer_data" do
|
188
|
-
it "raises an exception if any keys are invalid" do
|
189
|
-
expect do
|
190
|
-
Braintree::TransparentRedirect.update_customer_data(
|
191
|
-
:customer => {:first_name => "ok", :invalid_key => "bad"}
|
192
|
-
)
|
193
|
-
end.to raise_error(ArgumentError, "invalid keys: customer[invalid_key]")
|
194
|
-
end
|
195
|
-
|
196
|
-
it "raises an exception if not given a customer_id" do
|
197
|
-
expect do
|
198
|
-
Braintree::TransparentRedirect.update_customer_data({})
|
199
|
-
end.to raise_error(ArgumentError, "expected params to contain :customer_id of customer to update")
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe "self._data" do
|
204
|
-
it "raises an exception if :redirect_url isn't given" do
|
205
|
-
expect do
|
206
|
-
Braintree::TransparentRedirect.create_customer_data(:redirect_url => nil)
|
207
|
-
end.to raise_error(ArgumentError, "expected params to contain :redirect_url")
|
208
|
-
end
|
209
|
-
|
210
|
-
it "only encodes tr data once" do
|
211
|
-
tr_data = Braintree::TransparentRedirect.create_customer_data(:redirect_url => "example.com")
|
212
|
-
|
213
|
-
tr_data.should include("|")
|
214
|
-
tr_data.should include("&")
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
def add_hash_to_query_string(query_string_without_hash)
|
219
|
-
hash = Braintree::SignatureService.new(Braintree::Configuration.private_key).hash(query_string_without_hash)
|
220
|
-
query_string_without_hash + "&hash=" + hash
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|