braintree 2.104.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree.rb +7 -18
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +1 -23
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +12 -12
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -77
- data/lib/braintree/credit_card_gateway.rb +7 -36
- data/lib/braintree/credit_card_verification.rb +18 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -76
- data/lib/braintree/customer_gateway.rb +0 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +2 -8
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute_gateway.rb +4 -9
- data/lib/braintree/dispute_search.rb +2 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +151 -170
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/gateway.rb +0 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +2 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +3 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -14
- data/lib/braintree/payment_method_gateway.rb +8 -13
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +11 -11
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +44 -104
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +37 -25
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -2
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +21 -6
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +3 -3
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -29
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -43
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +1 -0
- data/lib/braintree/xml/parser.rb +21 -44
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +26 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
- data/spec/integration/braintree/credit_card_spec.rb +130 -593
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +336 -509
- data/spec/integration/braintree/dispute_search_spec.rb +6 -6
- data/spec/integration/braintree/dispute_spec.rb +6 -7
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
- data/spec/integration/braintree/payment_method_spec.rb +403 -269
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +144 -149
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +96 -70
- data/spec/integration/braintree/transaction_spec.rb +832 -904
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +10 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -14
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +9 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +5 -16
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_spec.rb +9 -20
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- 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_spec.rb +9 -5
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -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 +3 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -51
- data/spec/unit/braintree/util_spec.rb +55 -21
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +73 -57
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +30 -31
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- 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 -83
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/coinbase_details.rb +0 -16
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/braintree/xml/rexml.rb +0 -71
- 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/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -20,17 +20,6 @@ module Braintree
|
|
20
20
|
return_object_or_raise(:credit_card) { create(*args) }
|
21
21
|
end
|
22
22
|
|
23
|
-
# Deprecated
|
24
|
-
def create_credit_card_url
|
25
|
-
"#{@config.base_merchant_url}/payment_methods/all/create_via_transparent_redirect_request"
|
26
|
-
end
|
27
|
-
|
28
|
-
# Deprecated
|
29
|
-
def create_from_transparent_redirect(query_string)
|
30
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
31
|
-
_do_create("/payment_methods/all/confirm_transparent_redirect_request", :id => params[:id])
|
32
|
-
end
|
33
|
-
|
34
23
|
def credit(token, transaction_attributes)
|
35
24
|
@gateway.transaction.credit(transaction_attributes.merge(:payment_method_token => token))
|
36
25
|
end
|
@@ -49,8 +38,8 @@ module Braintree
|
|
49
38
|
end
|
50
39
|
|
51
40
|
def expiring_between(start_date, end_date, options = {})
|
52
|
-
formatted_start_date = start_date.strftime(
|
53
|
-
formatted_end_date = end_date.strftime(
|
41
|
+
formatted_start_date = start_date.strftime("%m%Y")
|
42
|
+
formatted_end_date = end_date.strftime("%m%Y")
|
54
43
|
response = @config.http.post("#{@config.base_merchant_path}/payment_methods/all/expiring_ids?start=#{formatted_start_date}&end=#{formatted_end_date}")
|
55
44
|
ResourceCollection.new(response) { |ids| _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) }
|
56
45
|
end
|
@@ -71,11 +60,6 @@ module Braintree
|
|
71
60
|
raise NotFoundError, "nonce #{nonce.inspect} locked, consumed, or not found"
|
72
61
|
end
|
73
62
|
|
74
|
-
# Deprecated in favor of PaymentMethodGateway.grant
|
75
|
-
def grant(token, allow_vaulting)
|
76
|
-
@gateway.payment_method.grant(token, allow_vaulting)
|
77
|
-
end
|
78
|
-
|
79
63
|
def update(token, attributes)
|
80
64
|
Util.verify_keys(CreditCardGateway._update_signature, attributes)
|
81
65
|
_do_update(:put, "/payment_methods/credit_card/#{token}", :credit_card => attributes)
|
@@ -85,19 +69,6 @@ module Braintree
|
|
85
69
|
return_object_or_raise(:credit_card) { update(*args) }
|
86
70
|
end
|
87
71
|
|
88
|
-
# Deprecated
|
89
|
-
def update_from_transparent_redirect(query_string)
|
90
|
-
warn "[DEPRECATED] CreditCard.update_via_transparent_redirect_request is deprecated. Please use TransparentRedirect.confirm"
|
91
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
92
|
-
_do_update(:post, "/payment_methods/all/confirm_transparent_redirect_request", :id => params[:id])
|
93
|
-
end
|
94
|
-
|
95
|
-
# Deprecated
|
96
|
-
def update_credit_card_url
|
97
|
-
warn "[DEPRECATED] CreditCard.update_credit_card_url is deprecated. Please use TransparentRedirect.url"
|
98
|
-
"#{@config.base_merchant_url}/payment_methods/all/update_via_transparent_redirect_request"
|
99
|
-
end
|
100
|
-
|
101
72
|
def self._create_signature # :nodoc:
|
102
73
|
_signature(:create)
|
103
74
|
end
|
@@ -108,11 +79,11 @@ module Braintree
|
|
108
79
|
|
109
80
|
def self._signature(type) # :nodoc:
|
110
81
|
billing_address_params = AddressGateway._shared_signature
|
111
|
-
options = [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]
|
82
|
+
options = [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type,:verification_currency_iso_code]
|
112
83
|
signature = [
|
113
|
-
:billing_address_id, :cardholder_name, :cvv, :
|
114
|
-
:
|
115
|
-
:
|
84
|
+
:billing_address_id, :cardholder_name, :cvv, :expiration_date, :expiration_month,
|
85
|
+
:expiration_year, :number, :token, :venmo_sdk_payment_method_code, :device_data,
|
86
|
+
:payment_method_nonce,
|
116
87
|
{:external_vault => [:network_transaction_id]},
|
117
88
|
{:options => options},
|
118
89
|
{:billing_address => billing_address_params}
|
@@ -174,7 +145,7 @@ module Braintree
|
|
174
145
|
def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) # :nodoc:
|
175
146
|
response = @config.http.post(
|
176
147
|
"#{@config.base_merchant_path}/payment_methods/all/expiring?start=#{formatted_start_date}&end=#{formatted_end_date}",
|
177
|
-
:search => {:ids => ids}
|
148
|
+
:search => {:ids => ids},
|
178
149
|
)
|
179
150
|
attributes = response[:payment_methods]
|
180
151
|
Util.extract_attribute_as_array(attributes, :credit_card).map { |attrs| CreditCard._new(@gateway, attrs) }
|
@@ -3,11 +3,24 @@ module Braintree
|
|
3
3
|
include BaseModule
|
4
4
|
include Braintree::Util::IdEquality
|
5
5
|
|
6
|
+
module GatewayRejectionReason
|
7
|
+
ApplicationIncomplete = "application_incomplete"
|
8
|
+
AVS = "avs"
|
9
|
+
AVSAndCVV = "avs_and_cvv"
|
10
|
+
CVV = "cvv"
|
11
|
+
Duplicate = "duplicate"
|
12
|
+
Fraud = "fraud"
|
13
|
+
RiskThreshold = "risk_threshold"
|
14
|
+
ThreeDSecure = "three_d_secure"
|
15
|
+
TokenIssuance = "token_issuance"
|
16
|
+
Unrecognized = "unrecognized"
|
17
|
+
end
|
18
|
+
|
6
19
|
module Status
|
7
|
-
Failed =
|
8
|
-
GatewayRejected =
|
9
|
-
ProcessorDeclined =
|
10
|
-
Verified =
|
20
|
+
Failed = "failed"
|
21
|
+
GatewayRejected = "gateway_rejected"
|
22
|
+
ProcessorDeclined = "processor_declined"
|
23
|
+
Verified = "verified"
|
11
24
|
|
12
25
|
All = [Failed, GatewayRejected, ProcessorDeclined, Verified]
|
13
26
|
end
|
@@ -79,7 +92,7 @@ module Braintree
|
|
79
92
|
end
|
80
93
|
|
81
94
|
def self._new(*args) # :nodoc:
|
82
|
-
self.new
|
95
|
+
self.new(*args)
|
83
96
|
end
|
84
97
|
|
85
98
|
def self.find(*args)
|
data/lib/braintree/customer.rb
CHANGED
@@ -4,11 +4,7 @@ module Braintree
|
|
4
4
|
include Braintree::Util::IdEquality
|
5
5
|
|
6
6
|
attr_reader :addresses
|
7
|
-
attr_reader :amex_express_checkout_cards # Deprecated
|
8
|
-
# NEXT_MAJOR_VERSION rename Android Pay to Google Pay
|
9
|
-
attr_reader :android_pay_cards
|
10
7
|
attr_reader :apple_pay_cards
|
11
|
-
attr_reader :coinbase_accounts
|
12
8
|
attr_reader :company
|
13
9
|
attr_reader :created_at
|
14
10
|
attr_reader :credit_cards
|
@@ -16,10 +12,10 @@ module Braintree
|
|
16
12
|
attr_reader :email
|
17
13
|
attr_reader :fax
|
18
14
|
attr_reader :first_name
|
15
|
+
attr_reader :google_pay_cards
|
19
16
|
attr_reader :graphql_id
|
20
17
|
attr_reader :id
|
21
18
|
attr_reader :last_name
|
22
|
-
attr_reader :masterpass_cards # Deprecated
|
23
19
|
attr_reader :paypal_accounts
|
24
20
|
attr_reader :phone
|
25
21
|
attr_reader :samsung_pay_cards
|
@@ -41,24 +37,12 @@ module Braintree
|
|
41
37
|
Configuration.gateway.customer.create!(*args)
|
42
38
|
end
|
43
39
|
|
44
|
-
# Deprecated. Use Braintree::TransparentRedirect.url
|
45
|
-
def self.create_customer_url
|
46
|
-
warn "[DEPRECATED] Customer.create_customer_url is deprecated. Please use TransparentRedirect.url"
|
47
|
-
Configuration.gateway.customer.create_customer_url
|
48
|
-
end
|
49
|
-
|
50
|
-
# Deprecated. Use Braintree::TransparentRedirect.confirm
|
51
|
-
def self.create_from_transparent_redirect(*args)
|
52
|
-
warn "[DEPRECATED] Customer.create_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
|
53
|
-
Configuration.gateway.customer.create_from_transparent_redirect(*args)
|
54
|
-
end
|
55
|
-
|
56
40
|
def self.credit(customer_id, transaction_attributes)
|
57
41
|
Transaction.credit(transaction_attributes.merge(:customer_id => customer_id))
|
58
42
|
end
|
59
43
|
|
60
44
|
def self.credit!(customer_id, transaction_attributes)
|
61
|
-
return_object_or_raise(:transaction){ credit(customer_id, transaction_attributes) }
|
45
|
+
return_object_or_raise(:transaction) { credit(customer_id, transaction_attributes) }
|
62
46
|
end
|
63
47
|
|
64
48
|
def self.delete(*args)
|
@@ -94,33 +78,16 @@ module Braintree
|
|
94
78
|
Configuration.gateway.customer.update!(*args)
|
95
79
|
end
|
96
80
|
|
97
|
-
# Deprecated. Use Braintree::TransparentRedirect.url
|
98
|
-
def self.update_customer_url
|
99
|
-
warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
|
100
|
-
Configuration.gateway.customer.update_customer_url
|
101
|
-
end
|
102
|
-
|
103
|
-
# Deprecated. Use Braintree::TransparentRedirect.confirm
|
104
|
-
def self.update_from_transparent_redirect(*args)
|
105
|
-
warn "[DEPRECATED] Customer.update_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
|
106
|
-
Configuration.gateway.customer.update_from_transparent_redirect(*args)
|
107
|
-
end
|
108
|
-
|
109
81
|
def initialize(gateway, attributes) # :nodoc:
|
110
82
|
@gateway = gateway
|
111
83
|
set_instance_variables_from_hash(attributes)
|
112
84
|
@credit_cards = (@credit_cards || []).map { |pm| CreditCard._new gateway, pm }
|
113
85
|
@paypal_accounts = (@paypal_accounts || []).map { |pm| PayPalAccount._new gateway, pm }
|
114
|
-
@coinbase_accounts = (@coinbase_accounts || []).map { |pm| CoinbaseAccount._new gateway, pm }
|
115
86
|
@apple_pay_cards = (@apple_pay_cards || []).map { |pm| ApplePayCard._new gateway, pm }
|
116
|
-
@
|
117
|
-
# NEXT_MAJOR_VERSION rename Android Pay to Google Pay
|
118
|
-
@android_pay_cards = (@android_pay_cards || []).map { |pm| AndroidPayCard._new gateway, pm }
|
119
|
-
@amex_express_checkout_cards = (@amex_express_checkout_cards || []).map { |pm| AmexExpressCheckoutCard._new gateway, pm }
|
87
|
+
@google_pay_cards = (@google_pay_cards || []).map { |pm| GooglePayCard._new gateway, pm }
|
120
88
|
@venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm }
|
121
89
|
@us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
|
122
90
|
@visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
|
123
|
-
@masterpass_cards = (@masterpass_cards|| []).map { |pm| MasterpassCard._new gateway, pm }
|
124
91
|
@samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm }
|
125
92
|
@addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
|
126
93
|
@custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
|
@@ -134,14 +101,6 @@ module Braintree
|
|
134
101
|
return_object_or_raise(:transaction) { credit(transaction_attributes) }
|
135
102
|
end
|
136
103
|
|
137
|
-
# Deprecated. Use Braintree::Customer.default_payment_method
|
138
|
-
#
|
139
|
-
# Returns the customer's default credit card.
|
140
|
-
def default_credit_card
|
141
|
-
warn "[DEPRECATED] Customer#default_credit_card is deprecated. Please use Customer#default_payment_method"
|
142
|
-
@credit_cards.find { |credit_card| credit_card.default? }
|
143
|
-
end
|
144
|
-
|
145
104
|
# Returns the customer's default payment method.
|
146
105
|
def default_payment_method
|
147
106
|
payment_methods.find { |payment_instrument| payment_instrument.default? }
|
@@ -156,9 +115,7 @@ module Braintree
|
|
156
115
|
@credit_cards +
|
157
116
|
@paypal_accounts +
|
158
117
|
@apple_pay_cards +
|
159
|
-
@
|
160
|
-
@android_pay_cards +
|
161
|
-
@amex_express_checkout_cards +
|
118
|
+
@google_pay_cards +
|
162
119
|
@venmo_accounts +
|
163
120
|
@us_bank_accounts +
|
164
121
|
@visa_checkout_cards +
|
@@ -175,45 +132,17 @@ module Braintree
|
|
175
132
|
"#<#{self.class} #{nice_attributes.join(', ')}>"
|
176
133
|
end
|
177
134
|
|
178
|
-
# Deprecated. Use Braintree::Customer.sale
|
179
|
-
def sale(transaction_attributes)
|
180
|
-
warn "[DEPRECATED] sale as an instance method is deprecated. Please use Customer.sale"
|
181
|
-
@gateway.transaction.sale(transaction_attributes.merge(:customer_id => id))
|
182
|
-
end
|
183
|
-
|
184
|
-
# Deprecated. Use Braintree::Customer.sale!
|
185
|
-
def sale!(transaction_attributes)
|
186
|
-
warn "[DEPRECATED] sale! as an instance method is deprecated. Please use Customer.sale!"
|
187
|
-
return_object_or_raise(:transaction) { sale(transaction_attributes) }
|
188
|
-
end
|
189
|
-
|
190
135
|
# Returns a ResourceCollection of transactions for the customer.
|
191
136
|
def transactions(options = {})
|
192
137
|
@gateway.customer.transactions(id, options)
|
193
138
|
end
|
194
139
|
|
195
|
-
# Deprecated. Use Braintree::Customer.update
|
196
|
-
def update(attributes)
|
197
|
-
warn "[DEPRECATED] update as an instance method is deprecated. Please use Customer.update"
|
198
|
-
result = @gateway.customer.update(id, attributes)
|
199
|
-
if result.success?
|
200
|
-
copy_instance_variables_from_object result.customer
|
201
|
-
end
|
202
|
-
result
|
203
|
-
end
|
204
|
-
|
205
|
-
# Deprecated. Use Braintree::Customer.update!
|
206
|
-
def update!(attributes)
|
207
|
-
warn "[DEPRECATED] update! as an instance method is deprecated. Please use Customer.update!"
|
208
|
-
return_object_or_raise(:customer) { update(attributes) }
|
209
|
-
end
|
210
|
-
|
211
140
|
class << self
|
212
141
|
protected :new
|
213
142
|
end
|
214
143
|
|
215
144
|
def self._new(*args) # :nodoc:
|
216
|
-
self.new
|
145
|
+
self.new(*args)
|
217
146
|
end
|
218
147
|
|
219
148
|
def self._attributes # :nodoc:
|
@@ -22,17 +22,6 @@ module Braintree
|
|
22
22
|
return_object_or_raise(:customer) { create(*args) }
|
23
23
|
end
|
24
24
|
|
25
|
-
# Deprecated
|
26
|
-
def create_customer_url
|
27
|
-
"#{@config.base_merchant_url}/customers/all/create_via_transparent_redirect_request"
|
28
|
-
end
|
29
|
-
|
30
|
-
# Deprecated
|
31
|
-
def create_from_transparent_redirect(query_string)
|
32
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
33
|
-
_do_create("/customers/all/confirm_transparent_redirect_request", :id => params[:id])
|
34
|
-
end
|
35
|
-
|
36
25
|
def delete(customer_id)
|
37
26
|
@config.http.delete("#{@config.base_merchant_path}/customers/#{customer_id}")
|
38
27
|
SuccessfulResult.new
|
@@ -71,18 +60,6 @@ module Braintree
|
|
71
60
|
return_object_or_raise(:customer) { update(*args) }
|
72
61
|
end
|
73
62
|
|
74
|
-
# Deprecated
|
75
|
-
def update_customer_url
|
76
|
-
warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
|
77
|
-
"#{@config.base_merchant_url}/customers/all/update_via_transparent_redirect_request"
|
78
|
-
end
|
79
|
-
|
80
|
-
# Deprecated
|
81
|
-
def update_from_transparent_redirect(query_string)
|
82
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string(query_string)
|
83
|
-
_do_update(:post, "/customers/all/confirm_transparent_redirect_request", :id => params[:id])
|
84
|
-
end
|
85
|
-
|
86
63
|
def self._create_signature # :nodoc:
|
87
64
|
credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
|
88
65
|
paypal_account_signature = PayPalAccountGateway._create_nested_signature
|
data/lib/braintree/dispute.rb
CHANGED
@@ -68,7 +68,7 @@ module Braintree
|
|
68
68
|
class << self
|
69
69
|
protected :new
|
70
70
|
def _new(*args) # :nodoc:
|
71
|
-
self.new
|
71
|
+
self.new(*args)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -118,14 +118,8 @@ module Braintree
|
|
118
118
|
@transaction = Transaction.new(transaction)
|
119
119
|
|
120
120
|
@status_history = status_history.map do |event|
|
121
|
-
Braintree::Dispute::
|
121
|
+
Braintree::Dispute::StatusHistory.new(event)
|
122
122
|
end unless status_history.nil?
|
123
123
|
end
|
124
|
-
|
125
|
-
def forwarded_comments
|
126
|
-
# NEXT_MAJOR_VERSION delete this method since it never returned anything anyway.
|
127
|
-
warn "[DEPRECATED] #forwarded_comments is deprecated. Please use #processor_comments"
|
128
|
-
processor_comments
|
129
|
-
end
|
130
124
|
end
|
131
125
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Braintree
|
2
2
|
class Dispute
|
3
|
-
class
|
3
|
+
class StatusHistory # :nodoc:
|
4
4
|
include BaseModule
|
5
5
|
|
6
6
|
attr_reader :disbursement_date
|
@@ -10,6 +10,8 @@ module Braintree
|
|
10
10
|
|
11
11
|
def initialize(attributes)
|
12
12
|
set_instance_variables_from_hash attributes unless attributes.nil?
|
13
|
+
@disbursement_date = Date.parse(disbursement_date) unless disbursement_date.nil?
|
14
|
+
@effective_date = Date.parse(effective_date) unless effective_date.nil?
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -25,7 +25,7 @@ module Braintree
|
|
25
25
|
raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
|
26
26
|
raise ArgumentError, "document_id_or_request cannot be blank" if document_id_or_request.nil?
|
27
27
|
|
28
|
-
request = document_id_or_request.is_a?(Hash) ? document_id_or_request : {
|
28
|
+
request = document_id_or_request.is_a?(Hash) ? document_id_or_request : {document_id: document_id_or_request}
|
29
29
|
|
30
30
|
raise ArgumentError, "document_id contains invalid characters" unless request[:document_id].to_s =~ /\A[\w-]+\z/
|
31
31
|
raise ArgumentError, "document_id cannot be blank" if request[:document_id].nil? || dispute_id.to_s.strip == ""
|
@@ -55,23 +55,18 @@ module Braintree
|
|
55
55
|
raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
|
56
56
|
raise ArgumentError, "content_or_request cannot be blank" if content_or_request.nil?
|
57
57
|
|
58
|
-
request = content_or_request.is_a?(String) ? {
|
58
|
+
request = content_or_request.is_a?(String) ? {content: content_or_request} : content_or_request
|
59
59
|
|
60
60
|
raise ArgumentError, "content cannot be blank" if request[:content].nil? || request[:content].to_s.strip == ""
|
61
|
-
raise ArgumentError, "request can only contain the keys [:content, :category, :sequence_number]" if (request.keys - [:category, :content, :
|
61
|
+
raise ArgumentError, "request can only contain the keys [:content, :category, :sequence_number]" if (request.keys - [:category, :content, :sequence_number]).any?
|
62
62
|
raise ArgumentError, "sequence_number must be an integer" if request[:sequence_number] && request[:sequence_number].to_s.match(/\D/)
|
63
|
-
raise ArgumentError, "tag must be a string" if request[:tag] && !request[:tag].is_a?(String)
|
64
63
|
raise ArgumentError, "category must be a string" if request[:category] && !request[:category].is_a?(String)
|
65
64
|
|
66
|
-
warn "[DEPRECATED] tag as an option is deprecated. Please use category" if request[:tag]
|
67
|
-
|
68
|
-
category = request[:category] || request[:tag]
|
69
|
-
|
70
65
|
params_for_http_post = {
|
71
66
|
evidence: {
|
72
67
|
comments: request[:content]
|
73
68
|
}.tap do |evidence_params|
|
74
|
-
evidence_params[:category] = category if category
|
69
|
+
evidence_params[:category] = request[:category] if request[:category]
|
75
70
|
evidence_params[:sequence_number] = request[:sequence_number] if request[:sequence_number]
|
76
71
|
end
|
77
72
|
}
|
@@ -5,7 +5,7 @@ module Braintree
|
|
5
5
|
:customer_id,
|
6
6
|
:id,
|
7
7
|
:reference_number,
|
8
|
-
:transaction_id
|
8
|
+
:transaction_id,
|
9
9
|
)
|
10
10
|
|
11
11
|
multiple_value_field :kind, :allows => Dispute::Kind::All
|
@@ -21,7 +21,7 @@ module Braintree
|
|
21
21
|
:disbursement_date,
|
22
22
|
:effective_date,
|
23
23
|
:received_date,
|
24
|
-
:reply_by_date
|
24
|
+
:reply_by_date,
|
25
25
|
)
|
26
26
|
end
|
27
27
|
end
|