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
data/lib/braintree/util.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Braintree
|
2
|
-
module Util
|
2
|
+
module Util
|
3
3
|
def self.extract_attribute_as_array(hash, attribute)
|
4
4
|
raise UnexpectedError.new("Unprocessable entity due to an invalid request") if hash.nil?
|
5
5
|
value = hash.has_key?(attribute) ? hash.delete(attribute) : []
|
@@ -14,13 +14,13 @@ module Braintree
|
|
14
14
|
else
|
15
15
|
url_encode(full_key) + "=" + url_encode(value)
|
16
16
|
end
|
17
|
-
end.sort *
|
17
|
+
end.sort * "&"
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.parse_query_string(qs)
|
21
|
-
qs.split(
|
22
|
-
pair = couplet.split(
|
23
|
-
result[CGI.unescape(pair[0]).to_sym] = CGI.unescape(pair[1] ||
|
21
|
+
qs.split("&").inject({}) do |result, couplet|
|
22
|
+
pair = couplet.split("=")
|
23
|
+
result[CGI.unescape(pair[0]).to_sym] = CGI.unescape(pair[1] || "")
|
24
24
|
result
|
25
25
|
end
|
26
26
|
end
|
@@ -53,6 +53,8 @@ module Braintree
|
|
53
53
|
raise AuthorizationError, message
|
54
54
|
when 404
|
55
55
|
raise NotFoundError
|
56
|
+
when 408
|
57
|
+
raise RequestTimeoutError
|
56
58
|
when 426
|
57
59
|
raise UpgradeRequiredError, "Please upgrade your client library."
|
58
60
|
when 429
|
@@ -60,7 +62,9 @@ module Braintree
|
|
60
62
|
when 500
|
61
63
|
raise ServerError
|
62
64
|
when 503
|
63
|
-
raise
|
65
|
+
raise ServiceUnavailableError
|
66
|
+
when 504
|
67
|
+
raise GatewayTimeoutError
|
64
68
|
else
|
65
69
|
raise UnexpectedError, "Unexpected HTTP_RESPONSE #{status_code.to_i}"
|
66
70
|
end
|
@@ -87,7 +91,7 @@ module Braintree
|
|
87
91
|
when "INTERNAL"
|
88
92
|
raise ServerError
|
89
93
|
when "SERVICE_AVAILABILITY"
|
90
|
-
raise
|
94
|
+
raise ServiceUnavailableError
|
91
95
|
else
|
92
96
|
raise UnexpectedError, "Unexpected Response: #{error[:message]}"
|
93
97
|
end
|
@@ -126,6 +130,17 @@ module Braintree
|
|
126
130
|
!invalid_keys.any?
|
127
131
|
end
|
128
132
|
|
133
|
+
def self.replace_key(hash, target_key, replacement_key)
|
134
|
+
hash.inject({}) do |new_hash, (key, value)|
|
135
|
+
if value.is_a?(Hash)
|
136
|
+
value = replace_key(value, target_key, replacement_key)
|
137
|
+
end
|
138
|
+
|
139
|
+
key = replacement_key if key == target_key
|
140
|
+
new_hash.merge(key => value)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
129
144
|
def self._flatten_valid_keys(valid_keys, namespace = nil)
|
130
145
|
valid_keys.inject([]) do |result, key|
|
131
146
|
if key.is_a?(Hash)
|
@@ -176,18 +191,18 @@ module Braintree
|
|
176
191
|
def self._get_invalid_keys(valid_keys, hash)
|
177
192
|
flattened_valid_keys = _flatten_valid_keys(valid_keys)
|
178
193
|
keys = _flatten_hash_keys(hash) - flattened_valid_keys
|
179
|
-
|
194
|
+
_remove_wildcard_keys(flattened_valid_keys, keys)
|
180
195
|
end
|
181
196
|
|
182
197
|
module IdEquality
|
183
|
-
def ==(other)
|
198
|
+
def ==(other)
|
184
199
|
return false unless other.is_a?(self.class)
|
185
200
|
id == other.id
|
186
201
|
end
|
187
202
|
end
|
188
203
|
|
189
204
|
module TokenEquality
|
190
|
-
def ==(other)
|
205
|
+
def ==(other)
|
191
206
|
return false unless other.is_a?(self.class)
|
192
207
|
token == other.token
|
193
208
|
end
|
@@ -2,7 +2,7 @@ module Braintree
|
|
2
2
|
class ValidationErrorCollection
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
-
def initialize(data)
|
5
|
+
def initialize(data)
|
6
6
|
return if !data.is_a? Hash
|
7
7
|
@errors = (data[:errors] || {}).map { |hash| Braintree::ValidationError.new(hash) }
|
8
8
|
@nested = {}
|
@@ -42,7 +42,7 @@ module Braintree
|
|
42
42
|
self.for("index_#{index}".to_sym)
|
43
43
|
end
|
44
44
|
|
45
|
-
def inspect
|
45
|
+
def inspect
|
46
46
|
"#<#{self.class} errors#{_inner_inspect}>"
|
47
47
|
end
|
48
48
|
|
@@ -61,7 +61,7 @@ module Braintree
|
|
61
61
|
@errors.size
|
62
62
|
end
|
63
63
|
|
64
|
-
def _inner_inspect(scope = [])
|
64
|
+
def _inner_inspect(scope = [])
|
65
65
|
all = []
|
66
66
|
scope_string = scope.join("/")
|
67
67
|
if @errors.any?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Braintree
|
2
2
|
class VenmoAccount
|
3
|
-
include BaseModule
|
3
|
+
include BaseModule
|
4
4
|
|
5
5
|
attr_reader :created_at
|
6
6
|
attr_reader :customer_id
|
@@ -13,7 +13,7 @@ module Braintree
|
|
13
13
|
attr_reader :username
|
14
14
|
attr_reader :venmo_user_id
|
15
15
|
|
16
|
-
def initialize(gateway, attributes)
|
16
|
+
def initialize(gateway, attributes)
|
17
17
|
@gateway = gateway
|
18
18
|
set_instance_variables_from_hash(attributes)
|
19
19
|
@subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
|
@@ -27,8 +27,8 @@ module Braintree
|
|
27
27
|
protected :new
|
28
28
|
end
|
29
29
|
|
30
|
-
def self._new(*args)
|
31
|
-
self.new
|
30
|
+
def self._new(*args)
|
31
|
+
self.new(*args)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Braintree
|
2
|
+
class VenmoProfileData
|
3
|
+
include BaseModule
|
4
|
+
|
5
|
+
attr_reader :billing_address
|
6
|
+
attr_reader :email
|
7
|
+
attr_reader :first_name
|
8
|
+
attr_reader :last_name
|
9
|
+
attr_reader :phone_number
|
10
|
+
attr_reader :shipping_address
|
11
|
+
attr_reader :username
|
12
|
+
|
13
|
+
def initialize(attributes)
|
14
|
+
set_instance_variables_from_hash(attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
protected :new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self._new(*args)
|
22
|
+
self.new(*args)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/braintree/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Braintree
|
2
2
|
class VisaCheckoutCard
|
3
|
-
include BaseModule
|
3
|
+
include BaseModule
|
4
4
|
include Braintree::Util::TokenEquality
|
5
5
|
|
6
6
|
attr_reader :billing_address
|
@@ -30,7 +30,7 @@ module Braintree
|
|
30
30
|
attr_reader :updated_at
|
31
31
|
attr_reader :verification
|
32
32
|
|
33
|
-
def initialize(gateway, attributes)
|
33
|
+
def initialize(gateway, attributes)
|
34
34
|
@gateway = gateway
|
35
35
|
set_instance_variables_from_hash(attributes)
|
36
36
|
@billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
|
@@ -39,8 +39,8 @@ module Braintree
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def _most_recent_verification(attributes)
|
42
|
-
|
43
|
-
CreditCardVerification._new(
|
42
|
+
sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
|
43
|
+
CreditCardVerification._new(sorted_verifications) if sorted_verifications
|
44
44
|
end
|
45
45
|
|
46
46
|
def default?
|
@@ -56,7 +56,7 @@ module Braintree
|
|
56
56
|
@expired
|
57
57
|
end
|
58
58
|
|
59
|
-
def inspect
|
59
|
+
def inspect
|
60
60
|
first = [:token]
|
61
61
|
order = first + (self.class._attributes - first)
|
62
62
|
nice_attributes = order.map do |attr|
|
@@ -73,7 +73,7 @@ module Braintree
|
|
73
73
|
protected :new
|
74
74
|
end
|
75
75
|
|
76
|
-
def self._attributes
|
76
|
+
def self._attributes
|
77
77
|
[
|
78
78
|
:billing_address, :bin, :card_type, :cardholder_name, :created_at,
|
79
79
|
:customer_id, :customer_location, :expiration_month, :expiration_year,
|
@@ -83,8 +83,8 @@ module Braintree
|
|
83
83
|
]
|
84
84
|
end
|
85
85
|
|
86
|
-
def self._new(*args)
|
87
|
-
self.new
|
86
|
+
def self._new(*args)
|
87
|
+
self.new(*args)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -1,19 +1,54 @@
|
|
1
|
-
require
|
1
|
+
require "ostruct"
|
2
2
|
|
3
3
|
module Braintree
|
4
4
|
class WebhookNotification
|
5
5
|
include BaseModule
|
6
6
|
|
7
7
|
module Kind
|
8
|
+
|
9
|
+
AccountUpdaterDailyReport = "account_updater_daily_report"
|
10
|
+
|
8
11
|
Check = "check"
|
9
12
|
|
13
|
+
ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
|
14
|
+
ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
|
10
15
|
Disbursement = "disbursement"
|
11
16
|
DisbursementException = "disbursement_exception"
|
12
17
|
|
13
|
-
|
18
|
+
DisputeAccepted = "dispute_accepted"
|
19
|
+
DisputeAutoAccepted = "dispute_auto_accepted"
|
20
|
+
DisputeDisputed = "dispute_disputed"
|
21
|
+
DisputeExpired = "dispute_expired"
|
14
22
|
DisputeLost = "dispute_lost"
|
23
|
+
DisputeOpened = "dispute_opened"
|
24
|
+
DisputeUnderReview = "dispute_under_review"
|
15
25
|
DisputeWon = "dispute_won"
|
16
26
|
|
27
|
+
GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"
|
28
|
+
|
29
|
+
GrantorUpdatedGrantedPaymentMethod = "grantor_updated_granted_payment_method"
|
30
|
+
GrantedPaymentMethodRevoked = "granted_payment_method_revoked"
|
31
|
+
|
32
|
+
LocalPaymentCompleted = "local_payment_completed"
|
33
|
+
LocalPaymentExpired = "local_payment_expired"
|
34
|
+
LocalPaymentFunded = "local_payment_funded"
|
35
|
+
LocalPaymentReversed = "local_payment_reversed"
|
36
|
+
|
37
|
+
OAuthAccessRevoked = "oauth_access_revoked"
|
38
|
+
|
39
|
+
PartnerMerchantConnected = "partner_merchant_connected"
|
40
|
+
PartnerMerchantDisconnected = "partner_merchant_disconnected"
|
41
|
+
PartnerMerchantDeclined = "partner_merchant_declined"
|
42
|
+
|
43
|
+
PaymentMethodCustomerDataUpdated = "payment_method_customer_data_updated"
|
44
|
+
|
45
|
+
PaymentMethodRevokedByCustomer = "payment_method_revoked_by_customer"
|
46
|
+
|
47
|
+
RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
|
48
|
+
|
49
|
+
RefundFailed = "refund_failed"
|
50
|
+
|
51
|
+
SubscriptionBillingSkipped = "subscription_billing_skipped"
|
17
52
|
SubscriptionCanceled = "subscription_canceled"
|
18
53
|
SubscriptionChargedSuccessfully = "subscription_charged_successfully"
|
19
54
|
SubscriptionChargedUnsuccessfully = "subscription_charged_unsuccessfully"
|
@@ -24,33 +59,11 @@ module Braintree
|
|
24
59
|
|
25
60
|
SubMerchantAccountApproved = "sub_merchant_account_approved"
|
26
61
|
SubMerchantAccountDeclined = "sub_merchant_account_declined"
|
62
|
+
|
27
63
|
TransactionDisbursed = "transaction_disbursed"
|
64
|
+
TransactionReviewed = "transaction_reviewed"
|
28
65
|
TransactionSettlementDeclined = "transaction_settlement_declined"
|
29
66
|
TransactionSettled = "transaction_settled"
|
30
|
-
PartnerMerchantConnected = "partner_merchant_connected"
|
31
|
-
PartnerMerchantDisconnected = "partner_merchant_disconnected"
|
32
|
-
PartnerMerchantDeclined = "partner_merchant_declined"
|
33
|
-
|
34
|
-
AccountUpdaterDailyReport = "account_updater_daily_report"
|
35
|
-
|
36
|
-
# NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
|
37
|
-
# DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
|
38
|
-
IdealPaymentComplete = "ideal_payment_complete"
|
39
|
-
IdealPaymentFailed = "ideal_payment_failed"
|
40
|
-
|
41
|
-
OAuthAccessRevoked = "oauth_access_revoked"
|
42
|
-
ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
|
43
|
-
ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
|
44
|
-
|
45
|
-
# NEXT_MAJOR_VERSION remove GrantedPaymentInstrumentUpdate. Kind is not sent by Braintree Gateway.
|
46
|
-
# Kind will either be GrantorUpdatedGrantedPaymentMethod or RecipientUpdatedGrantedPaymentMethod.
|
47
|
-
GrantedPaymentInstrumentUpdate = "granted_payment_instrument_update"
|
48
|
-
GrantorUpdatedGrantedPaymentMethod = "grantor_updated_granted_payment_method"
|
49
|
-
RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
|
50
|
-
GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"
|
51
|
-
PaymentMethodRevokedByCustomer = "payment_method_revoked_by_customer"
|
52
|
-
|
53
|
-
LocalPaymentCompleted = "local_payment_completed"
|
54
67
|
end
|
55
68
|
|
56
69
|
attr_reader :account_updater_daily_report
|
@@ -60,15 +73,19 @@ module Braintree
|
|
60
73
|
attr_reader :dispute
|
61
74
|
attr_reader :granted_payment_instrument_update
|
62
75
|
attr_reader :revoked_payment_method_metadata
|
63
|
-
attr_reader :ideal_payment
|
64
76
|
attr_reader :kind
|
65
77
|
attr_reader :local_payment_completed
|
78
|
+
attr_reader :local_payment_expired
|
79
|
+
attr_reader :local_payment_funded
|
80
|
+
attr_reader :local_payment_reversed
|
66
81
|
attr_reader :oauth_access_revocation
|
67
82
|
attr_reader :partner_merchant
|
83
|
+
attr_reader :payment_method_customer_data_updated_metadata
|
68
84
|
attr_reader :source_merchant_id
|
69
85
|
attr_reader :subscription
|
70
86
|
attr_reader :timestamp
|
71
87
|
attr_reader :transaction
|
88
|
+
attr_reader :transaction_review
|
72
89
|
|
73
90
|
def self.parse(*args)
|
74
91
|
Configuration.gateway.webhook_notification.parse(*args)
|
@@ -78,7 +95,7 @@ module Braintree
|
|
78
95
|
Configuration.gateway.webhook_notification.verify(*args)
|
79
96
|
end
|
80
97
|
|
81
|
-
def initialize(gateway, attributes)
|
98
|
+
def initialize(gateway, attributes)
|
82
99
|
@gateway = gateway
|
83
100
|
set_instance_variables_from_hash(attributes)
|
84
101
|
@error_result = ErrorResult.new(gateway, @subject[:api_error_response]) if @subject.has_key?(:api_error_response)
|
@@ -87,15 +104,20 @@ module Braintree
|
|
87
104
|
@oauth_access_revocation = OpenStruct.new(@subject[:oauth_application_revocation]) if @subject.has_key?(:oauth_application_revocation)
|
88
105
|
@subscription = Subscription._new(gateway, @subject[:subscription]) if @subject.has_key?(:subscription)
|
89
106
|
@transaction = Transaction._new(gateway, @subject[:transaction]) if @subject.has_key?(:transaction)
|
107
|
+
@transaction_review = OpenStruct.new(@subject[:transaction_review]) if @subject.has_key?(:transaction_review)
|
90
108
|
@disbursement = Disbursement._new(gateway, @subject[:disbursement]) if @subject.has_key?(:disbursement)
|
91
109
|
@dispute = Dispute._new(@subject[:dispute]) if @subject.has_key?(:dispute)
|
92
110
|
@account_updater_daily_report = AccountUpdaterDailyReport._new(@subject[:account_updater_daily_report]) if @subject.has_key?(:account_updater_daily_report)
|
93
|
-
@ideal_payment = Braintree::IdealPayment._new(gateway, @subject[:ideal_payment]) if @subject.has_key?(:ideal_payment)
|
94
111
|
@connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned._new(@subject[:connected_merchant_status_transitioned]) if @subject.has_key?(:connected_merchant_status_transitioned)
|
95
112
|
@connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged._new(@subject[:connected_merchant_paypal_status_changed]) if @subject.has_key?(:connected_merchant_paypal_status_changed)
|
96
113
|
@granted_payment_instrument_update = GrantedPaymentInstrumentUpdate._new(@subject[:granted_payment_instrument_update]) if @subject.has_key?(:granted_payment_instrument_update)
|
97
|
-
@revoked_payment_method_metadata = RevokedPaymentMethodMetadata._new(gateway, @subject) if [Kind::GrantedPaymentInstrumentRevoked, Kind::PaymentMethodRevokedByCustomer].include?(@kind)
|
98
|
-
@local_payment_completed = LocalPaymentCompleted._new(@subject[:local_payment]) if @subject.has_key?(:local_payment)
|
114
|
+
@revoked_payment_method_metadata = RevokedPaymentMethodMetadata._new(gateway, @subject) if [Kind::GrantedPaymentInstrumentRevoked, Kind::PaymentMethodRevokedByCustomer, Kind::GrantedPaymentMethodRevoked].include?(@kind)
|
115
|
+
@local_payment_completed = LocalPaymentCompleted._new(@subject[:local_payment]) if @subject.has_key?(:local_payment) && Kind::LocalPaymentCompleted == @kind
|
116
|
+
@local_payment_expired = LocalPaymentExpired._new(@subject[:local_payment_expired]) if @subject.has_key?(:local_payment_expired) && Kind::LocalPaymentExpired == @kind
|
117
|
+
@local_payment_funded = LocalPaymentFunded._new(@subject[:local_payment_funded]) if @subject.has_key?(:local_payment_funded) && Kind::LocalPaymentFunded == @kind
|
118
|
+
@local_payment_reversed = LocalPaymentReversed._new(@subject[:local_payment_reversed]) if @subject.has_key?(:local_payment_reversed) && Kind::LocalPaymentReversed == @kind
|
119
|
+
@payment_method_customer_data_updated_metadata = PaymentMethodCustomerDataUpdatedMetadata._new(gateway, @subject[:payment_method_customer_data_updated_metadata]) if @subject.has_key?(:payment_method_customer_data_updated_metadata) && Kind::PaymentMethodCustomerDataUpdated == @kind
|
120
|
+
|
99
121
|
end
|
100
122
|
|
101
123
|
def merchant_account
|
@@ -116,8 +138,8 @@ module Braintree
|
|
116
138
|
|
117
139
|
class << self
|
118
140
|
protected :new
|
119
|
-
def _new(*args)
|
120
|
-
self.new
|
141
|
+
def _new(*args)
|
142
|
+
self.new(*args)
|
121
143
|
end
|
122
144
|
end
|
123
145
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Braintree
|
2
|
-
class WebhookNotificationGateway
|
2
|
+
class WebhookNotificationGateway
|
3
3
|
def initialize(gateway)
|
4
4
|
@gateway = gateway
|
5
5
|
@config = gateway.config
|
@@ -7,8 +7,8 @@ module Braintree
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def parse(signature_string, payload)
|
10
|
-
raise InvalidSignature,
|
11
|
-
raise InvalidSignature,
|
10
|
+
raise InvalidSignature, "signature cannot be nil" if signature_string.nil?
|
11
|
+
raise InvalidSignature, "payload cannot be nil" if payload.nil?
|
12
12
|
if payload =~ /[^A-Za-z0-9+=\/\n]/
|
13
13
|
raise InvalidSignature, "payload contains illegal characters"
|
14
14
|
end
|
@@ -18,7 +18,7 @@ module Braintree
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def verify(challenge)
|
21
|
-
raise InvalidChallenge,
|
21
|
+
raise InvalidChallenge, "challenge contains non-hex characters" unless challenge =~ /\A[a-f0-9]{20,32}\z/
|
22
22
|
digest = Braintree::Digest.hexdigest(@config.private_key, challenge)
|
23
23
|
"#{@config.public_key}|#{digest}"
|
24
24
|
end
|
@@ -27,20 +27,20 @@ module Braintree
|
|
27
27
|
signature_pairs = signature_string.split("&")
|
28
28
|
valid_pairs = signature_pairs.select { |pair| pair.include?("|") }.map { |pair| pair.split("|") }
|
29
29
|
|
30
|
-
valid_pairs.detect do |public_key,
|
30
|
+
valid_pairs.detect do |public_key, _signature|
|
31
31
|
public_key == @config.public_key
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def _verify_signature(signature_string, payload)
|
36
36
|
public_key, signature = _matching_signature_pair(signature_string)
|
37
|
-
raise InvalidSignature,
|
37
|
+
raise InvalidSignature, "no matching public key" if public_key.nil?
|
38
38
|
|
39
|
-
signature_matches = [payload, payload + "\n"].any? do |
|
40
|
-
payload_signature = Braintree::Digest.hexdigest(@config.private_key,
|
39
|
+
signature_matches = [payload, payload + "\n"].any? do |p|
|
40
|
+
payload_signature = Braintree::Digest.hexdigest(@config.private_key, p)
|
41
41
|
Braintree::Digest.secure_compare(signature, payload_signature)
|
42
42
|
end
|
43
|
-
raise InvalidSignature,
|
43
|
+
raise InvalidSignature, "signature does not match payload - one has been modified" unless signature_matches
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|