braintree 2.74.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/braintree.gemspec +13 -7
- data/lib/braintree/account_updater_daily_report.rb +2 -2
- data/lib/braintree/ach_mandate.rb +2 -1
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +30 -38
- data/lib/braintree/address_gateway.rb +12 -2
- data/lib/braintree/advanced_search.rb +8 -0
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +28 -4
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +10 -0
- data/lib/braintree/bin_data.rb +33 -0
- data/lib/braintree/client_token.rb +3 -3
- data/lib/braintree/client_token_gateway.rb +3 -1
- data/lib/braintree/configuration.rb +57 -10
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
- data/lib/braintree/credentials_parser.rb +5 -1
- data/lib/braintree/credit_card.rb +53 -107
- data/lib/braintree/credit_card_gateway.rb +43 -30
- data/lib/braintree/credit_card_verification.rb +61 -21
- data/lib/braintree/credit_card_verification_gateway.rb +19 -6
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +51 -98
- data/lib/braintree/customer_gateway.rb +30 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +3 -1
- data/lib/braintree/disbursement.rb +24 -2
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +2 -1
- data/lib/braintree/dispute.rb +114 -10
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +328 -109
- data/lib/braintree/error_result.rb +8 -1
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +21 -0
- data/lib/braintree/facilitator_details.rb +2 -1
- data/lib/braintree/gateway.rb +29 -11
- data/lib/braintree/google_pay_card.rb +61 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql_client.rb +34 -0
- data/lib/braintree/http.rb +81 -20
- data/lib/braintree/local_payment_completed.rb +23 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +11 -4
- data/lib/braintree/merchant_account/address_details.rb +4 -1
- data/lib/braintree/merchant_account/business_details.rb +4 -1
- data/lib/braintree/merchant_account/funding_details.rb +6 -1
- data/lib/braintree/merchant_account/individual_details.rb +7 -2
- data/lib/braintree/merchant_account.rb +23 -10
- data/lib/braintree/merchant_account_gateway.rb +13 -1
- data/lib/braintree/merchant_gateway.rb +2 -2
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +5 -2
- data/lib/braintree/oauth_gateway.rb +8 -14
- data/lib/braintree/paginated_result.rb +3 -1
- data/lib/braintree/payment_instrument_type.rb +11 -11
- data/lib/braintree/payment_method.rb +20 -12
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +82 -54
- data/lib/braintree/payment_method_nonce.rb +22 -8
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
- data/lib/braintree/payment_method_parser.rb +28 -0
- data/lib/braintree/paypal_account.rb +10 -1
- data/lib/braintree/plan.rb +25 -5
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +12 -2
- data/lib/braintree/samsung_pay_card.rb +83 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
- data/lib/braintree/subscription/status_details.rb +8 -1
- data/lib/braintree/subscription.rb +56 -41
- data/lib/braintree/subscription_gateway.rb +25 -2
- data/lib/braintree/successful_result.rb +23 -1
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +13 -0
- data/lib/braintree/test/nonce.rb +28 -20
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +34 -2
- data/lib/braintree/transaction/address_details.rb +24 -4
- data/lib/braintree/transaction/apple_pay_details.rb +20 -2
- data/lib/braintree/transaction/credit_card_details.rb +45 -6
- data/lib/braintree/transaction/customer_details.rb +8 -1
- data/lib/braintree/transaction/disbursement_details.rb +6 -1
- data/lib/braintree/transaction/google_pay_details.rb +41 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +24 -0
- data/lib/braintree/transaction/paypal_details.rb +26 -4
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +5 -1
- data/lib/braintree/transaction/subscription_details.rb +4 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
- data/lib/braintree/transaction/venmo_account_details.rb +5 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
- data/lib/braintree/transaction.rb +201 -188
- data/lib/braintree/transaction_gateway.rb +124 -30
- data/lib/braintree/transaction_line_item.rb +40 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +6 -3
- data/lib/braintree/unknown_payment_method.rb +3 -2
- data/lib/braintree/us_bank_account.rb +24 -8
- data/lib/braintree/us_bank_account_gateway.rb +0 -1
- data/lib/braintree/us_bank_account_verification.rb +81 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +79 -9
- data/lib/braintree/validation_error.rb +13 -3
- data/lib/braintree/validation_error_collection.rb +2 -1
- data/lib/braintree/venmo_account.rb +11 -4
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +29 -13
- data/lib/braintree/webhook_notification.rb +66 -26
- data/lib/braintree/webhook_notification_gateway.rb +5 -3
- data/lib/braintree/webhook_testing.rb +2 -2
- data/lib/braintree/webhook_testing_gateway.rb +721 -55
- data/lib/braintree/xml/generator.rb +6 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +60 -22
- data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +3 -3
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
- data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
- data/spec/integration/braintree/credit_card_spec.rb +460 -615
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +810 -498
- data/spec/integration/braintree/discount_spec.rb +1 -1
- data/spec/integration/braintree/dispute_search_spec.rb +167 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +12 -4
- data/spec/integration/braintree/merchant_account_spec.rb +74 -26
- data/spec/integration/braintree/merchant_spec.rb +39 -13
- data/spec/integration/braintree/oauth_spec.rb +18 -25
- data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
- data/spec/integration/braintree/payment_method_spec.rb +882 -300
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
- data/spec/integration/braintree/paypal_account_spec.rb +32 -31
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +274 -180
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +18 -18
- data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
- data/spec/integration/braintree/transaction_search_spec.rb +280 -152
- data/spec/integration/braintree/transaction_spec.rb +3709 -1175
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +27 -6
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +26 -23
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +108 -33
- data/spec/unit/braintree/credit_card_spec.rb +62 -33
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
- data/spec/unit/braintree/customer_spec.rb +107 -27
- data/spec/unit/braintree/disbursement_spec.rb +59 -7
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +472 -8
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +93 -5
- data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +40 -6
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/subscription_spec.rb +2 -2
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +171 -55
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
- data/spec/unit/braintree/util_spec.rb +162 -19
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -24
- data/spec/unit/braintree_spec.rb +1 -0
- metadata +290 -198
- data/README.rdoc +0 -93
- data/lib/braintree/amex_express_checkout_card.rb +0 -26
- data/lib/braintree/android_pay_card.rb +0 -35
- data/lib/braintree/coinbase_account.rb +0 -25
- data/lib/braintree/europe_bank_account.rb +0 -34
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -46
- data/lib/braintree/ideal_payment_gateway.rb +0 -18
- data/lib/braintree/masterpass_card.rb +0 -66
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
- data/lib/braintree/transaction/android_pay_details.rb +0 -17
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/httpsd.pid +0 -1
- data/spec/integration/braintree/coinbase_spec.rb +0 -31
- data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -1,7 +1,8 @@
|
|
1
1
|
module Braintree
|
2
2
|
class Configuration
|
3
|
-
API_VERSION = "
|
3
|
+
API_VERSION = "6" # :nodoc:
|
4
4
|
DEFAULT_ENDPOINT = "api" # :nodoc:
|
5
|
+
GRAPHQL_API_VERSION = "2018-09-10" # :nodoc:
|
5
6
|
|
6
7
|
READABLE_ATTRIBUTES = [
|
7
8
|
:merchant_id,
|
@@ -39,11 +40,12 @@ module Braintree
|
|
39
40
|
]
|
40
41
|
|
41
42
|
class << self
|
42
|
-
attr_writer
|
43
|
-
attr_reader
|
43
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
44
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
44
45
|
end
|
45
|
-
attr_reader
|
46
|
-
attr_reader
|
46
|
+
attr_reader(*READABLE_ATTRIBUTES)
|
47
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
48
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
47
49
|
|
48
50
|
def self.expectant_reader(*attributes) # :nodoc:
|
49
51
|
attributes.each do |attribute|
|
@@ -54,7 +56,7 @@ module Braintree
|
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
57
|
-
expectant_reader
|
59
|
+
expectant_reader(*READABLE_ATTRIBUTES)
|
58
60
|
|
59
61
|
# Sets the Braintree environment to use. Valid values are <tt>:sandbox</tt> and <tt>:production</tt>
|
60
62
|
def self.environment=(env)
|
@@ -84,7 +86,7 @@ module Braintree
|
|
84
86
|
:proxy_port => proxy_port,
|
85
87
|
:proxy_user => proxy_user,
|
86
88
|
:proxy_pass => proxy_pass,
|
87
|
-
:ssl_version => ssl_version
|
89
|
+
:ssl_version => ssl_version,
|
88
90
|
)
|
89
91
|
end
|
90
92
|
|
@@ -113,6 +115,8 @@ module Braintree
|
|
113
115
|
instance_variable_set "@#{attr}", options[attr]
|
114
116
|
end
|
115
117
|
|
118
|
+
@environment = @environment.to_sym if @environment
|
119
|
+
|
116
120
|
_check_for_mixed_credentials(options)
|
117
121
|
|
118
122
|
parser = Braintree::CredentialsParser.new
|
@@ -123,6 +127,9 @@ module Braintree
|
|
123
127
|
@environment = parser.environment
|
124
128
|
elsif options[:access_token]
|
125
129
|
parser.parse_access_token(options[:access_token])
|
130
|
+
|
131
|
+
_check_for_mixed_environment(options[:environment], parser.environment)
|
132
|
+
|
126
133
|
@access_token = parser.access_token
|
127
134
|
@environment = parser.environment
|
128
135
|
@merchant_id = parser.merchant_id
|
@@ -145,10 +152,20 @@ module Braintree
|
|
145
152
|
end
|
146
153
|
end
|
147
154
|
|
155
|
+
def _check_for_mixed_environment(options_environment, token_environment)
|
156
|
+
if options_environment && options_environment.to_sym != token_environment.to_sym
|
157
|
+
warn "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used."
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
148
161
|
def api_version # :nodoc:
|
149
162
|
API_VERSION
|
150
163
|
end
|
151
164
|
|
165
|
+
def graphql_api_version # :nodoc:
|
166
|
+
GRAPHQL_API_VERSION
|
167
|
+
end
|
168
|
+
|
152
169
|
def base_merchant_path # :nodoc:
|
153
170
|
"/merchants/#{merchant_id}"
|
154
171
|
end
|
@@ -157,6 +174,10 @@ module Braintree
|
|
157
174
|
"#{protocol}://#{server}:#{port}"
|
158
175
|
end
|
159
176
|
|
177
|
+
def graphql_base_url
|
178
|
+
"#{protocol}://#{graphql_server}:#{graphql_port}/graphql"
|
179
|
+
end
|
180
|
+
|
160
181
|
def base_merchant_url # :nodoc:
|
161
182
|
"#{base_url}#{base_merchant_path}"
|
162
183
|
end
|
@@ -173,6 +194,10 @@ module Braintree
|
|
173
194
|
Http.new(self)
|
174
195
|
end
|
175
196
|
|
197
|
+
def graphql_client
|
198
|
+
GraphQLClient.new(self)
|
199
|
+
end
|
200
|
+
|
176
201
|
def logger
|
177
202
|
@logger ||= self.class._default_logger
|
178
203
|
end
|
@@ -180,7 +205,16 @@ module Braintree
|
|
180
205
|
def port # :nodoc:
|
181
206
|
case @environment
|
182
207
|
when :development, :integration
|
183
|
-
ENV[
|
208
|
+
ENV["GATEWAY_PORT"] || 3000
|
209
|
+
when :production, :qa, :sandbox
|
210
|
+
443
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def graphql_port # :nodoc:
|
215
|
+
case @environment
|
216
|
+
when :development, :integration
|
217
|
+
ENV["GRAPHQL_PORT"] || 8080
|
184
218
|
when :production, :qa, :sandbox
|
185
219
|
443
|
186
220
|
end
|
@@ -201,7 +235,7 @@ module Braintree
|
|
201
235
|
def server # :nodoc:
|
202
236
|
case @environment
|
203
237
|
when :development, :integration
|
204
|
-
"localhost"
|
238
|
+
ENV["GATEWAY_HOST"] || "localhost"
|
205
239
|
when :production
|
206
240
|
"#{endpoint}.braintreegateway.com"
|
207
241
|
when :qa
|
@@ -211,6 +245,19 @@ module Braintree
|
|
211
245
|
end
|
212
246
|
end
|
213
247
|
|
248
|
+
def graphql_server # :nodoc:
|
249
|
+
case @environment
|
250
|
+
when :development, :integration
|
251
|
+
ENV["GRAPHQL_HOST"] || "graphql.bt.local"
|
252
|
+
when :production
|
253
|
+
"payments.braintree-api.com"
|
254
|
+
when :qa
|
255
|
+
"payments-qa.dev.braintree-api.com"
|
256
|
+
when :sandbox
|
257
|
+
"payments.sandbox.braintree-api.com"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
214
261
|
def auth_url
|
215
262
|
case @environment
|
216
263
|
when :development, :integration
|
@@ -260,7 +307,7 @@ module Braintree
|
|
260
307
|
|
261
308
|
def assert_has_access_token_or_keys
|
262
309
|
if (public_key.nil? || private_key.nil?) && access_token.nil?
|
263
|
-
raise ConfigurationError.new("Braintree::Gateway public_key and private_key are required.")
|
310
|
+
raise ConfigurationError.new("Braintree::Gateway access_token or public_key and private_key are required.")
|
264
311
|
end
|
265
312
|
end
|
266
313
|
|
@@ -2,7 +2,11 @@ module Braintree
|
|
2
2
|
class ConnectedMerchantPayPalStatusChanged
|
3
3
|
include BaseModule
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :action
|
6
|
+
attr_reader :merchant_public_id
|
7
|
+
attr_reader :oauth_application_client_id
|
8
|
+
|
9
|
+
alias_method :merchant_id, :merchant_public_id
|
6
10
|
|
7
11
|
def initialize(attributes)
|
8
12
|
set_instance_variables_from_hash(attributes)
|
@@ -11,7 +15,7 @@ module Braintree
|
|
11
15
|
class << self
|
12
16
|
protected :new
|
13
17
|
def _new(*args) # :nodoc:
|
14
|
-
self.new
|
18
|
+
self.new(*args)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -2,7 +2,11 @@ module Braintree
|
|
2
2
|
class ConnectedMerchantStatusTransitioned
|
3
3
|
include BaseModule
|
4
4
|
|
5
|
-
attr_reader :merchant_public_id
|
5
|
+
attr_reader :merchant_public_id
|
6
|
+
attr_reader :oauth_application_client_id
|
7
|
+
attr_reader :status
|
8
|
+
|
9
|
+
alias_method :merchant_id, :merchant_public_id
|
6
10
|
|
7
11
|
def initialize(attributes)
|
8
12
|
set_instance_variables_from_hash(attributes)
|
@@ -11,7 +15,7 @@ module Braintree
|
|
11
15
|
class << self
|
12
16
|
protected :new
|
13
17
|
def _new(*args) # :nodoc:
|
14
|
-
self.new
|
18
|
+
self.new(*args)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Braintree
|
2
2
|
class CredentialsParser
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :access_token
|
4
|
+
attr_reader :client_id
|
5
|
+
attr_reader :client_secret
|
6
|
+
attr_reader :environment
|
7
|
+
attr_reader :merchant_id
|
4
8
|
|
5
9
|
def parse_client_credentials(client_id, client_secret)
|
6
10
|
raise ConfigurationError.new("Missing client_id when constructing Braintree::Gateway") if client_id.nil?
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Braintree
|
2
2
|
class CreditCard
|
3
3
|
include BaseModule # :nodoc:
|
4
|
+
include Braintree::Util::TokenEquality
|
4
5
|
|
5
6
|
module CardType
|
6
7
|
AmEx = "American Express"
|
@@ -8,8 +9,10 @@ module Braintree
|
|
8
9
|
ChinaUnionPay = "China UnionPay"
|
9
10
|
DinersClubInternational = "Diners Club"
|
10
11
|
Discover = "Discover"
|
12
|
+
Elo = "Elo"
|
11
13
|
JCB = "JCB"
|
12
14
|
Laser = "Laser"
|
15
|
+
UK_Maestro = "UK Maestro"
|
13
16
|
Maestro = "Maestro"
|
14
17
|
MasterCard = "MasterCard"
|
15
18
|
Solo = "Solo"
|
@@ -34,29 +37,37 @@ module Braintree
|
|
34
37
|
Commercial = Debit = DurbinRegulated = Healthcare = Payroll = Prepaid = ProductId =
|
35
38
|
IssuingBank = CountryOfIssuance = CardTypeIndicator
|
36
39
|
|
37
|
-
attr_reader :billing_address
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
40
|
+
attr_reader :billing_address
|
41
|
+
attr_reader :bin
|
42
|
+
attr_reader :card_type
|
43
|
+
attr_reader :cardholder_name
|
44
|
+
attr_reader :commercial
|
45
|
+
attr_reader :country_of_issuance
|
46
|
+
attr_reader :created_at
|
47
|
+
attr_reader :customer_id
|
48
|
+
attr_reader :debit
|
49
|
+
attr_reader :durbin_regulated
|
50
|
+
attr_reader :expiration_month
|
51
|
+
attr_reader :expiration_year
|
52
|
+
attr_reader :healthcare
|
53
|
+
attr_reader :image_url
|
54
|
+
attr_reader :issuing_bank
|
55
|
+
attr_reader :last_4
|
56
|
+
attr_reader :payroll
|
57
|
+
attr_reader :prepaid
|
58
|
+
attr_reader :product_id
|
59
|
+
attr_reader :subscriptions
|
60
|
+
attr_reader :token
|
61
|
+
attr_reader :unique_number_identifier
|
62
|
+
attr_reader :updated_at
|
63
|
+
attr_reader :verification
|
64
|
+
|
65
|
+
def self.create(*args)
|
66
|
+
Configuration.gateway.credit_card.create(*args)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.create!(*args)
|
70
|
+
Configuration.gateway.credit_card.create!(*args)
|
60
71
|
end
|
61
72
|
|
62
73
|
def self.credit(token, transaction_attributes)
|
@@ -67,29 +78,24 @@ module Braintree
|
|
67
78
|
return_object_or_raise(:transaction) { credit(token, transaction_attributes) }
|
68
79
|
end
|
69
80
|
|
70
|
-
def self.delete(
|
71
|
-
Configuration.gateway.credit_card.delete(
|
81
|
+
def self.delete(*args)
|
82
|
+
Configuration.gateway.credit_card.delete(*args)
|
72
83
|
end
|
73
84
|
|
74
|
-
def self.expired(
|
75
|
-
Configuration.gateway.credit_card.expired(
|
85
|
+
def self.expired(*args)
|
86
|
+
Configuration.gateway.credit_card.expired(*args)
|
76
87
|
end
|
77
88
|
|
78
|
-
def self.expiring_between(
|
79
|
-
Configuration.gateway.credit_card.expiring_between(
|
89
|
+
def self.expiring_between(*args)
|
90
|
+
Configuration.gateway.credit_card.expiring_between(*args)
|
80
91
|
end
|
81
92
|
|
82
|
-
def self.find(
|
83
|
-
Configuration.gateway.credit_card.find(
|
93
|
+
def self.find(*args)
|
94
|
+
Configuration.gateway.credit_card.find(*args)
|
84
95
|
end
|
85
96
|
|
86
|
-
def self.from_nonce(
|
87
|
-
Configuration.gateway.credit_card.from_nonce(
|
88
|
-
end
|
89
|
-
|
90
|
-
# Deprecated. Use Braintree::PaymentMethod.grant
|
91
|
-
def self.grant(token, allow_vaulting)
|
92
|
-
Configuration.gateway.credit_card.grant(token, allow_vaulting)
|
97
|
+
def self.from_nonce(*args)
|
98
|
+
Configuration.gateway.credit_card.from_nonce(*args)
|
93
99
|
end
|
94
100
|
|
95
101
|
def self.sale(token, transaction_attributes)
|
@@ -100,24 +106,12 @@ module Braintree
|
|
100
106
|
return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
|
101
107
|
end
|
102
108
|
|
103
|
-
def self.update(
|
104
|
-
Configuration.gateway.credit_card.update(
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.update!(token, attributes)
|
108
|
-
return_object_or_raise(:credit_card) { update(token, attributes) }
|
109
|
+
def self.update(*args)
|
110
|
+
Configuration.gateway.credit_card.update(*args)
|
109
111
|
end
|
110
112
|
|
111
|
-
|
112
|
-
|
113
|
-
warn "[DEPRECATED] CreditCard.update_via_transparent_redirect_request is deprecated. Please use TransparentRedirect.confirm"
|
114
|
-
Configuration.gateway.credit_card.update_from_transparent_redirect(query_string)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Deprecated. Use Braintree::TransparentRedirect.url
|
118
|
-
def self.update_credit_card_url
|
119
|
-
warn "[DEPRECATED] CreditCard.update_credit_card_url is deprecated. Please use TransparentRedirect.url"
|
120
|
-
Configuration.gateway.credit_card.update_credit_card_url
|
113
|
+
def self.update!(*args)
|
114
|
+
Configuration.gateway.credit_card.update!(*args)
|
121
115
|
end
|
122
116
|
|
123
117
|
def initialize(gateway, attributes) # :nodoc:
|
@@ -129,28 +123,10 @@ module Braintree
|
|
129
123
|
end
|
130
124
|
|
131
125
|
def _most_recent_verification(attributes)
|
132
|
-
verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
|
126
|
+
verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
|
133
127
|
CreditCardVerification._new(verification) if verification
|
134
128
|
end
|
135
129
|
|
136
|
-
# Deprecated. Use Braintree::CreditCard.credit
|
137
|
-
def credit(transaction_attributes)
|
138
|
-
warn "[DEPRECATED] credit as an instance method is deprecated. Please use CreditCard.credit"
|
139
|
-
@gateway.transaction.credit(transaction_attributes.merge(:payment_method_token => token))
|
140
|
-
end
|
141
|
-
|
142
|
-
# Deprecated. Use Braintree::CreditCard.credit!
|
143
|
-
def credit!(transaction_attributes)
|
144
|
-
warn "[DEPRECATED] credit! as an instance method is deprecated. Please use CreditCard.credit!"
|
145
|
-
return_object_or_raise(:transaction) { credit(transaction_attributes) }
|
146
|
-
end
|
147
|
-
|
148
|
-
# Deprecated. Use Braintree::CreditCard.delete
|
149
|
-
def delete
|
150
|
-
warn "[DEPRECATED] delete as an instance method is deprecated. Please use CreditCard.delete"
|
151
|
-
@gateway.credit_card.delete(token)
|
152
|
-
end
|
153
|
-
|
154
130
|
# Returns true if this credit card is the customer's default payment method.
|
155
131
|
def default?
|
156
132
|
@default
|
@@ -179,34 +155,6 @@ module Braintree
|
|
179
155
|
"#{bin}******#{last_4}"
|
180
156
|
end
|
181
157
|
|
182
|
-
# Deprecated. Use Braintree::CreditCard.sale
|
183
|
-
def sale(transaction_attributes)
|
184
|
-
warn "[DEPRECATED] sale as an instance method is deprecated. Please use CreditCard.sale"
|
185
|
-
@gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
|
186
|
-
end
|
187
|
-
|
188
|
-
# Deprecated. Use Braintree::CreditCard.sale!
|
189
|
-
def sale!(transaction_attributes)
|
190
|
-
warn "[DEPRECATED] sale! as an instance method is deprecated. Please use CreditCard.sale!"
|
191
|
-
return_object_or_raise(:transaction) { sale(transaction_attributes) }
|
192
|
-
end
|
193
|
-
|
194
|
-
# Deprecated. Use Braintree::CreditCard.update
|
195
|
-
def update(attributes)
|
196
|
-
warn "[DEPRECATED] update as an instance method is deprecated. Please use CreditCard.update"
|
197
|
-
result = @gateway.credit_card.update(token, attributes)
|
198
|
-
if result.success?
|
199
|
-
copy_instance_variables_from_object result.credit_card
|
200
|
-
end
|
201
|
-
result
|
202
|
-
end
|
203
|
-
|
204
|
-
# Deprecated. Use Braintree::CreditCard.update!
|
205
|
-
def update!(attributes)
|
206
|
-
warn "[DEPRECATED] update! as an instance method is deprecated. Please use CreditCard.update!"
|
207
|
-
return_object_or_raise(:credit_card) { update(attributes) }
|
208
|
-
end
|
209
|
-
|
210
158
|
def nonce
|
211
159
|
@nonce ||= PaymentMethodNonce.create(token)
|
212
160
|
end
|
@@ -216,10 +164,8 @@ module Braintree
|
|
216
164
|
@venmo_sdk
|
217
165
|
end
|
218
166
|
|
219
|
-
|
220
|
-
|
221
|
-
return false unless other.is_a?(CreditCard)
|
222
|
-
token == other.token
|
167
|
+
def is_network_tokenized?
|
168
|
+
@is_network_tokenized
|
223
169
|
end
|
224
170
|
|
225
171
|
class << self
|
@@ -230,12 +176,12 @@ module Braintree
|
|
230
176
|
[
|
231
177
|
:billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
|
232
178
|
:expiration_year, :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, :commercial, :debit, :durbin_regulated,
|
233
|
-
:healthcare, :country_of_issuance, :issuing_bank, :image_url
|
179
|
+
:healthcare, :country_of_issuance, :issuing_bank, :image_url, :is_network_tokenized?
|
234
180
|
]
|
235
181
|
end
|
236
182
|
|
237
183
|
def self._new(*args) # :nodoc:
|
238
|
-
self.new
|
184
|
+
self.new(*args)
|
239
185
|
end
|
240
186
|
end
|
241
187
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Braintree
|
2
2
|
class CreditCardGateway # :nodoc:
|
3
|
+
include BaseModule
|
4
|
+
|
3
5
|
def initialize(gateway)
|
4
6
|
@gateway = gateway
|
5
7
|
@config = gateway.config
|
@@ -14,15 +16,16 @@ module Braintree
|
|
14
16
|
_do_create("/payment_methods", :credit_card => attributes)
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def create!(*args)
|
20
|
+
return_object_or_raise(:credit_card) { create(*args) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def credit(token, transaction_attributes)
|
24
|
+
@gateway.transaction.credit(transaction_attributes.merge(:payment_method_token => token))
|
20
25
|
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
25
|
-
_do_create("/payment_methods/all/confirm_transparent_redirect_request", :id => params[:id])
|
27
|
+
def credit!(*args)
|
28
|
+
return_object_or_raise(:transaction) { credit(*args) }
|
26
29
|
end
|
27
30
|
|
28
31
|
def delete(token)
|
@@ -35,8 +38,8 @@ module Braintree
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def expiring_between(start_date, end_date, options = {})
|
38
|
-
formatted_start_date = start_date.strftime(
|
39
|
-
formatted_end_date = end_date.strftime(
|
41
|
+
formatted_start_date = start_date.strftime("%m%Y")
|
42
|
+
formatted_end_date = end_date.strftime("%m%Y")
|
40
43
|
response = @config.http.post("#{@config.base_merchant_path}/payment_methods/all/expiring_ids?start=#{formatted_start_date}&end=#{formatted_end_date}")
|
41
44
|
ResourceCollection.new(response) { |ids| _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) }
|
42
45
|
end
|
@@ -57,27 +60,13 @@ module Braintree
|
|
57
60
|
raise NotFoundError, "nonce #{nonce.inspect} locked, consumed, or not found"
|
58
61
|
end
|
59
62
|
|
60
|
-
# Deprecated in favor of PaymentMethodGateway.grant
|
61
|
-
def grant(token, allow_vaulting)
|
62
|
-
@gateway.payment_method.grant(token, allow_vaulting)
|
63
|
-
end
|
64
|
-
|
65
63
|
def update(token, attributes)
|
66
64
|
Util.verify_keys(CreditCardGateway._update_signature, attributes)
|
67
65
|
_do_update(:put, "/payment_methods/credit_card/#{token}", :credit_card => attributes)
|
68
66
|
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
warn "[DEPRECATED] CreditCard.update_via_transparent_redirect_request is deprecated. Please use TransparentRedirect.confirm"
|
73
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
74
|
-
_do_update(:post, "/payment_methods/all/confirm_transparent_redirect_request", :id => params[:id])
|
75
|
-
end
|
76
|
-
|
77
|
-
# Deprecated
|
78
|
-
def update_credit_card_url
|
79
|
-
warn "[DEPRECATED] CreditCard.update_credit_card_url is deprecated. Please use TransparentRedirect.url"
|
80
|
-
"#{@config.base_merchant_url}/payment_methods/all/update_via_transparent_redirect_request"
|
68
|
+
def update!(*args)
|
69
|
+
return_object_or_raise(:credit_card) { update(*args) }
|
81
70
|
end
|
82
71
|
|
83
72
|
def self._create_signature # :nodoc:
|
@@ -90,15 +79,39 @@ module Braintree
|
|
90
79
|
|
91
80
|
def self._signature(type) # :nodoc:
|
92
81
|
billing_address_params = AddressGateway._shared_signature
|
93
|
-
options = [
|
82
|
+
options = [
|
83
|
+
:fail_on_duplicate_payment_method,
|
84
|
+
:make_default,
|
85
|
+
:skip_advanced_fraud_checking,
|
86
|
+
:venmo_sdk_session,
|
87
|
+
:verification_account_type,
|
88
|
+
:verification_amount,
|
89
|
+
:verification_currency_iso_code,
|
90
|
+
:verification_merchant_account_id,
|
91
|
+
:verify_card
|
92
|
+
]
|
94
93
|
signature = [
|
95
|
-
:billing_address_id, :cardholder_name, :cvv, :
|
96
|
-
:
|
97
|
-
:
|
94
|
+
:billing_address_id, :cardholder_name, :cvv, :expiration_date, :expiration_month,
|
95
|
+
:expiration_year, :number, :token, :venmo_sdk_payment_method_code, :device_data,
|
96
|
+
:payment_method_nonce,
|
97
|
+
{:external_vault => [:network_transaction_id]},
|
98
98
|
{:options => options},
|
99
99
|
{:billing_address => billing_address_params}
|
100
100
|
]
|
101
101
|
|
102
|
+
signature << {
|
103
|
+
:three_d_secure_pass_thru => [
|
104
|
+
:eci_flag,
|
105
|
+
:cavv,
|
106
|
+
:xid,
|
107
|
+
:three_d_secure_version,
|
108
|
+
:authentication_response,
|
109
|
+
:directory_response,
|
110
|
+
:cavv_algorithm,
|
111
|
+
:ds_transaction_id,
|
112
|
+
]
|
113
|
+
}
|
114
|
+
|
102
115
|
case type
|
103
116
|
when :create
|
104
117
|
signature << :customer_id
|
@@ -142,7 +155,7 @@ module Braintree
|
|
142
155
|
def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) # :nodoc:
|
143
156
|
response = @config.http.post(
|
144
157
|
"#{@config.base_merchant_path}/payment_methods/all/expiring?start=#{formatted_start_date}&end=#{formatted_end_date}",
|
145
|
-
:search => {:ids => ids}
|
158
|
+
:search => {:ids => ids},
|
146
159
|
)
|
147
160
|
attributes = response[:payment_methods]
|
148
161
|
Util.extract_attribute_as_array(attributes, :credit_card).map { |attrs| CreditCard._new(@gateway, attrs) }
|