braintree 3.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/braintree.gemspec +2 -3
- data/lib/braintree.rb +8 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -1
- 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/bin_data.rb +9 -2
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- 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 -2
- data/lib/braintree/credit_card_gateway.rb +4 -4
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +6 -4
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +15 -1
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +3 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +10 -2
- data/lib/braintree/google_pay_card.rb +1 -1
- 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 +1 -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 -10
- data/lib/braintree/payment_method_gateway.rb +4 -6
- data/lib/braintree/payment_method_nonce.rb +1 -1
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- 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 +6 -6
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +43 -26
- 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_gateway.rb +26 -5
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- 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 +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -19
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +0 -1
- data/lib/braintree/xml/parser.rb +22 -12
- data/lib/braintree/xml/rexml.rb +70 -0
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +28 -24
- 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 -5
- data/spec/integration/braintree/credit_card_spec.rb +124 -122
- 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 +343 -149
- data/spec/integration/braintree/dispute_search_spec.rb +29 -4
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- 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 +26 -35
- data/spec/integration/braintree/payment_method_spec.rb +326 -149
- 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 +133 -133
- 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 +93 -67
- data/spec/integration/braintree/transaction_spec.rb +736 -380
- 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 +9 -3
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- 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 -9
- 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 +14 -4
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +34 -9
- 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 +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -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_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 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +15 -19
- data/lib/braintree/settlement_batch.rb +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
module Braintree
|
2
|
+
class PaymentMethodNonceDetailsPayerInfo # :nodoc:
|
3
|
+
include BaseModule
|
4
|
+
|
5
|
+
attr_reader :billing_agreement_id
|
6
|
+
attr_reader :country_code
|
7
|
+
attr_reader :email
|
8
|
+
attr_reader :first_name
|
9
|
+
attr_reader :last_name
|
10
|
+
attr_reader :payer_id
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def inspect
|
17
|
+
attr_order = [
|
18
|
+
:billing_agreement_id,
|
19
|
+
:country_code,
|
20
|
+
:email,
|
21
|
+
:first_name,
|
22
|
+
:last_name,
|
23
|
+
:payer_id,
|
24
|
+
]
|
25
|
+
|
26
|
+
formatted_attrs = attr_order.map do |attr|
|
27
|
+
"#{attr}: #{send(attr).inspect}"
|
28
|
+
end
|
29
|
+
"#<PaymentMethodNonceDetailsPayerInfo #{formatted_attrs.join(", ")}>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -8,7 +8,7 @@ module Braintree
|
|
8
8
|
@config.assert_has_access_token_or_keys
|
9
9
|
end
|
10
10
|
|
11
|
-
def create(payment_method_token, args = {
|
11
|
+
def create(payment_method_token, args = {payment_method_nonce: {}})
|
12
12
|
Util.verify_keys(PaymentMethodNonceGateway._create_signature, args)
|
13
13
|
|
14
14
|
response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces", args)
|
data/lib/braintree/plan.rb
CHANGED
@@ -22,9 +22,14 @@ module Braintree
|
|
22
22
|
@ids.empty?
|
23
23
|
end
|
24
24
|
|
25
|
-
# Returns the first
|
26
|
-
def first
|
27
|
-
@
|
25
|
+
# Returns the first or the first N items in the collection or nil if the collection is empty
|
26
|
+
def first(amount = 1)
|
27
|
+
return nil if @ids.empty?
|
28
|
+
return @paging_block.call([@ids.first]).first if amount == 1
|
29
|
+
|
30
|
+
@ids.first(amount).each_slice(@page_size).flat_map do |page_of_ids|
|
31
|
+
@paging_block.call(page_of_ids)
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
35
|
# Only the maximum size of a resource collection can be determined since the data on the server can change while
|
data/lib/braintree/risk_data.rb
CHANGED
@@ -6,16 +6,18 @@ module Braintree
|
|
6
6
|
attr_reader :customer_location_zip
|
7
7
|
attr_reader :customer_tenure
|
8
8
|
attr_reader :decision
|
9
|
+
attr_reader :decision_reasons
|
9
10
|
attr_reader :device_data_captured
|
10
11
|
attr_reader :fraud_service_provider
|
11
12
|
attr_reader :id
|
13
|
+
attr_reader :transaction_risk_score
|
12
14
|
|
13
15
|
def initialize(attributes)
|
14
16
|
set_instance_variables_from_hash attributes unless attributes.nil?
|
15
17
|
end
|
16
18
|
|
17
19
|
def inspect
|
18
|
-
attr_order = [:id, :decision, :device_data_captured, :fraud_service_provider]
|
20
|
+
attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :transaction_risk_score]
|
19
21
|
formatted_attrs = attr_order.map do |attr|
|
20
22
|
"#{attr}: #{send(attr).inspect}"
|
21
23
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Braintree
|
2
2
|
class SettlementBatchSummary
|
3
3
|
include BaseModule
|
4
|
-
|
4
|
+
|
5
5
|
attr_reader :records
|
6
6
|
|
7
7
|
def self.generate(settlement_date, group_by_custom_field = nil)
|
8
|
-
criteria = {
|
8
|
+
criteria = {:settlement_date => settlement_date}
|
9
9
|
criteria.merge!({:group_by_custom_field => group_by_custom_field}) if group_by_custom_field
|
10
10
|
Configuration.gateway.settlement_batch_summary.generate(criteria)
|
11
11
|
end
|
@@ -11,11 +11,11 @@ module Braintree
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module Status
|
14
|
-
Active =
|
15
|
-
Canceled =
|
16
|
-
Expired =
|
17
|
-
PastDue =
|
18
|
-
Pending =
|
14
|
+
Active = "Active"
|
15
|
+
Canceled = "Canceled"
|
16
|
+
Expired = "Expired"
|
17
|
+
PastDue = "Past Due"
|
18
|
+
Pending = "Pending"
|
19
19
|
|
20
20
|
All = constants.map { |c| const_get(c) }
|
21
21
|
end
|
@@ -115,7 +115,7 @@ module Braintree
|
|
115
115
|
class << self
|
116
116
|
protected :new
|
117
117
|
def _new(*args) # :nodoc:
|
118
|
-
self.new
|
118
|
+
self.new(*args)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -2,16 +2,21 @@ module Braintree
|
|
2
2
|
class ThreeDSecureInfo # :nodoc:
|
3
3
|
include BaseModule
|
4
4
|
|
5
|
+
attr_reader :acs_transaction_id
|
6
|
+
attr_reader :cavv
|
7
|
+
attr_reader :ds_transaction_id
|
8
|
+
attr_reader :eci_flag
|
5
9
|
attr_reader :enrolled
|
6
|
-
attr_reader :liability_shifted
|
7
10
|
attr_reader :liability_shift_possible
|
11
|
+
attr_reader :liability_shifted
|
12
|
+
attr_reader :pares_status
|
8
13
|
attr_reader :status
|
9
|
-
attr_reader :cavv
|
10
|
-
attr_reader :xid
|
11
|
-
attr_reader :eci_flag
|
12
|
-
attr_reader :three_d_secure_version
|
13
|
-
attr_reader :ds_transaction_id
|
14
14
|
attr_reader :three_d_secure_authentication_id
|
15
|
+
attr_reader :three_d_secure_transaction_id
|
16
|
+
attr_reader :three_d_secure_version
|
17
|
+
attr_reader :xid
|
18
|
+
attr_reader :lookup
|
19
|
+
attr_reader :authentication
|
15
20
|
|
16
21
|
alias_method :liability_shifted?, :liability_shifted
|
17
22
|
alias_method :liability_shift_possible?, :liability_shift_possible
|
@@ -22,16 +27,21 @@ module Braintree
|
|
22
27
|
|
23
28
|
def inspect
|
24
29
|
attr_order = [
|
30
|
+
:acs_transaction_id,
|
31
|
+
:authentication,
|
32
|
+
:cavv,
|
33
|
+
:ds_transaction_id,
|
34
|
+
:eci_flag,
|
25
35
|
:enrolled,
|
26
|
-
:liability_shifted,
|
27
36
|
:liability_shift_possible,
|
37
|
+
:liability_shifted,
|
38
|
+
:lookup,
|
39
|
+
:pares_status,
|
28
40
|
:status,
|
29
|
-
:cavv,
|
30
|
-
:xid,
|
31
|
-
:eci_flag,
|
32
|
-
:three_d_secure_version,
|
33
|
-
:ds_transaction_id,
|
34
41
|
:three_d_secure_authentication_id,
|
42
|
+
:three_d_secure_transaction_id,
|
43
|
+
:three_d_secure_version,
|
44
|
+
:xid
|
35
45
|
]
|
36
46
|
|
37
47
|
formatted_attrs = attr_order.map do |attr|
|
@@ -4,18 +4,18 @@ module Braintree
|
|
4
4
|
include Braintree::Util::IdEquality
|
5
5
|
|
6
6
|
module CreatedUsing
|
7
|
-
FullInformation =
|
8
|
-
Token =
|
9
|
-
Unrecognized =
|
7
|
+
FullInformation = "full_information"
|
8
|
+
Token = "token"
|
9
|
+
Unrecognized = "unrecognized"
|
10
10
|
end
|
11
11
|
|
12
12
|
module EscrowStatus
|
13
|
-
HoldPending =
|
14
|
-
Held =
|
15
|
-
ReleasePending =
|
16
|
-
Released =
|
17
|
-
Refunded =
|
18
|
-
Unrecognized =
|
13
|
+
HoldPending = "hold_pending"
|
14
|
+
Held = "held"
|
15
|
+
ReleasePending = "release_pending"
|
16
|
+
Released = "released"
|
17
|
+
Refunded = "refunded"
|
18
|
+
Unrecognized = "unrecognized"
|
19
19
|
end
|
20
20
|
|
21
21
|
module GatewayRejectionReason
|
@@ -32,20 +32,20 @@ module Braintree
|
|
32
32
|
end
|
33
33
|
|
34
34
|
module Status
|
35
|
-
AuthorizationExpired =
|
36
|
-
Authorizing =
|
37
|
-
Authorized =
|
38
|
-
GatewayRejected =
|
39
|
-
Failed =
|
40
|
-
ProcessorDeclined =
|
41
|
-
Settled =
|
42
|
-
SettlementConfirmed =
|
43
|
-
SettlementDeclined =
|
44
|
-
SettlementPending =
|
45
|
-
Settling =
|
46
|
-
SubmittedForSettlement =
|
47
|
-
Voided =
|
48
|
-
Unrecognized =
|
35
|
+
AuthorizationExpired = "authorization_expired"
|
36
|
+
Authorizing = "authorizing"
|
37
|
+
Authorized = "authorized"
|
38
|
+
GatewayRejected = "gateway_rejected"
|
39
|
+
Failed = "failed"
|
40
|
+
ProcessorDeclined = "processor_declined"
|
41
|
+
Settled = "settled"
|
42
|
+
SettlementConfirmed = "settlement_confirmed"
|
43
|
+
SettlementDeclined = "settlement_declined"
|
44
|
+
SettlementPending = "settlement_pending"
|
45
|
+
Settling = "settling"
|
46
|
+
SubmittedForSettlement = "submitted_for_settlement"
|
47
|
+
Voided = "voided"
|
48
|
+
Unrecognized = "unrecognized"
|
49
49
|
|
50
50
|
All = constants.map { |c| const_get(c) }
|
51
51
|
end
|
@@ -90,10 +90,10 @@ module Braintree
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
attr_reader :acquirer_reference_number
|
93
94
|
attr_reader :add_ons
|
94
95
|
attr_reader :additional_processor_response # The raw response from the processor.
|
95
96
|
attr_reader :amount
|
96
|
-
attr_reader :google_pay_details
|
97
97
|
attr_reader :apple_pay_details
|
98
98
|
attr_reader :authorization_adjustments
|
99
99
|
attr_reader :authorization_expires_at
|
@@ -118,8 +118,11 @@ module Braintree
|
|
118
118
|
attr_reader :facilitated_details
|
119
119
|
attr_reader :facilitator_details
|
120
120
|
attr_reader :gateway_rejection_reason
|
121
|
+
attr_reader :google_pay_details
|
121
122
|
attr_reader :graphql_id
|
122
123
|
attr_reader :id
|
124
|
+
attr_reader :installment_count
|
125
|
+
attr_reader :installments
|
123
126
|
attr_reader :local_payment_details
|
124
127
|
attr_reader :merchant_account_id
|
125
128
|
attr_reader :network_response_code # Response code from the card network
|
@@ -142,8 +145,11 @@ module Braintree
|
|
142
145
|
attr_reader :recurring
|
143
146
|
attr_reader :refund_ids
|
144
147
|
attr_reader :refunded_transaction_id
|
148
|
+
attr_reader :refunded_installments
|
149
|
+
attr_reader :retrieval_reference_number
|
145
150
|
attr_reader :risk_data
|
146
151
|
attr_reader :samsung_pay_card_details
|
152
|
+
attr_reader :sca_exemption_requested
|
147
153
|
attr_reader :service_fee_amount
|
148
154
|
attr_reader :settlement_batch_id
|
149
155
|
attr_reader :shipping_amount
|
@@ -162,7 +168,14 @@ module Braintree
|
|
162
168
|
attr_reader :venmo_account_details
|
163
169
|
attr_reader :visa_checkout_card_details
|
164
170
|
attr_reader :voice_referral_number
|
165
|
-
|
171
|
+
|
172
|
+
def self.adjust_authorization(*args)
|
173
|
+
Configuration.gateway.transaction.adjust_authorization(*args)
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.adjust_authorization!(*args)
|
177
|
+
Configuration.gateway.transaction.adjust_authorization!(*args)
|
178
|
+
end
|
166
179
|
|
167
180
|
def self.create(*args)
|
168
181
|
Configuration.gateway.transaction.create(*args)
|
@@ -304,7 +317,11 @@ module Braintree
|
|
304
317
|
@us_bank_account_details = UsBankAccountDetails.new(attributes[:us_bank_account]) if attributes[:us_bank_account]
|
305
318
|
@visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])
|
306
319
|
@samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
|
320
|
+
@sca_exemption_requested = attributes[:sca_exemption_requested]
|
307
321
|
authorization_adjustments.map! { |attrs| AuthorizationAdjustment._new(attrs) } if authorization_adjustments
|
322
|
+
|
323
|
+
installments.map! { |attrs| Installment.new(attrs) } if installments
|
324
|
+
refunded_installments.map! { |attrs| Installment.new(attrs) } if refunded_installments
|
308
325
|
end
|
309
326
|
|
310
327
|
def inspect # :nodoc:
|
@@ -377,7 +394,7 @@ module Braintree
|
|
377
394
|
class << self
|
378
395
|
protected :new
|
379
396
|
def _new(*args) # :nodoc:
|
380
|
-
self.new
|
397
|
+
self.new(*args)
|
381
398
|
end
|
382
399
|
end
|
383
400
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class Installment
|
4
|
+
include BaseModule
|
5
|
+
|
6
|
+
attr_reader :id
|
7
|
+
attr_reader :amount
|
8
|
+
attr_reader :projected_disbursement_date
|
9
|
+
attr_reader :actual_disbursement_date
|
10
|
+
attr_reader :adjustments
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
14
|
+
@amount = Util.to_big_decimal(amount)
|
15
|
+
adjustments.map! { |attrs| Adjustment.new(attrs) } if adjustments
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
attrs = [:id, :amount, :projected_disbursement_date, :actual_disbursement_date, :adjustments]
|
20
|
+
formatted_attrs = attrs.map do |attr|
|
21
|
+
"#{attr}: #{send(attr).inspect}"
|
22
|
+
end
|
23
|
+
|
24
|
+
"#<#{formatted_attrs.join(", ")}>"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class Installment
|
4
|
+
class Adjustment
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
module Kind
|
8
|
+
Refund = "REFUND"
|
9
|
+
Dispute = "DISPUTE"
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :amount
|
13
|
+
attr_reader :kind
|
14
|
+
attr_reader :projected_disbursement_date
|
15
|
+
attr_reader :actual_disbursement_date
|
16
|
+
|
17
|
+
def initialize(attributes)
|
18
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
19
|
+
@amount = Util.to_big_decimal(amount)
|
20
|
+
end
|
21
|
+
|
22
|
+
def inspect
|
23
|
+
attrs = [:amount, :kind, :projected_disbursement_date, :actual_disbursement_date]
|
24
|
+
formatted_attrs = attrs.map do |attr|
|
25
|
+
"#{attr}: #{send(attr).inspect}"
|
26
|
+
end
|
27
|
+
|
28
|
+
"#<#{formatted_attrs.join(", ")}>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -53,7 +53,7 @@ module Braintree
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def credit(attributes)
|
56
|
-
create(attributes.merge(:type =>
|
56
|
+
create(attributes.merge(:type => "credit"))
|
57
57
|
end
|
58
58
|
|
59
59
|
def credit!(*args)
|
@@ -72,7 +72,7 @@ module Braintree
|
|
72
72
|
options = if amount_or_options.is_a?(Hash)
|
73
73
|
amount_or_options
|
74
74
|
else
|
75
|
-
{
|
75
|
+
{:amount => amount_or_options}
|
76
76
|
end
|
77
77
|
|
78
78
|
Util.verify_keys(TransactionGateway._refund_signature, options)
|
@@ -97,7 +97,7 @@ module Braintree
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def sale(attributes)
|
100
|
-
create(attributes.merge(:type =>
|
100
|
+
create(attributes.merge(:type => "sale"))
|
101
101
|
end
|
102
102
|
|
103
103
|
def sale!(*args)
|
@@ -139,6 +139,18 @@ module Braintree
|
|
139
139
|
return_object_or_raise(:transaction) { submit_for_settlement(*args) }
|
140
140
|
end
|
141
141
|
|
142
|
+
def adjust_authorization(transaction_id, amount)
|
143
|
+
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
144
|
+
Util.verify_keys(TransactionGateway._adjust_authorization_signature, {})
|
145
|
+
transaction_params = {:amount => amount}
|
146
|
+
response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/adjust_authorization", :transaction => transaction_params)
|
147
|
+
_handle_transaction_response(response)
|
148
|
+
end
|
149
|
+
|
150
|
+
def adjust_authorization!(*args)
|
151
|
+
return_object_or_raise(:transaction) { adjust_authorization(*args) }
|
152
|
+
end
|
153
|
+
|
142
154
|
def update_details(transaction_id, options = {})
|
143
155
|
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
144
156
|
Util.verify_keys(TransactionGateway._update_details_signature, options)
|
@@ -180,6 +192,7 @@ module Braintree
|
|
180
192
|
:shared_shipping_address_id, :shipping_address_id, :shipping_amount,
|
181
193
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,
|
182
194
|
:three_d_secure_token, :transaction_source, :type, :venmo_sdk_payment_method_code,
|
195
|
+
:sca_exemption, :currency_iso_code,
|
183
196
|
{:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
|
184
197
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
185
198
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number]},
|
@@ -245,7 +258,8 @@ module Braintree
|
|
245
258
|
]},
|
246
259
|
]},
|
247
260
|
{:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
|
248
|
-
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
|
261
|
+
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
|
262
|
+
{:installments => [:count]},
|
249
263
|
]
|
250
264
|
end
|
251
265
|
|
@@ -263,6 +277,12 @@ module Braintree
|
|
263
277
|
]
|
264
278
|
end
|
265
279
|
|
280
|
+
def self._adjust_authorization_signature
|
281
|
+
[
|
282
|
+
:amount
|
283
|
+
]
|
284
|
+
end
|
285
|
+
|
266
286
|
def self._update_details_signature # :nodoc:
|
267
287
|
[
|
268
288
|
:amount,
|
@@ -274,7 +294,8 @@ module Braintree
|
|
274
294
|
def self._refund_signature
|
275
295
|
[
|
276
296
|
:amount,
|
277
|
-
:
|
297
|
+
:merchant_account_id,
|
298
|
+
:order_id,
|
278
299
|
]
|
279
300
|
end
|
280
301
|
|