braintree 4.15.0 → 4.16.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/lib/braintree/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- 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 +9 -9
- data/lib/braintree/credit_card_gateway.rb +8 -8
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +1 -1
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +8 -7
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- 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 +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +3 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +1 -1
- data/lib/braintree/transaction/credit_card_details.rb +1 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- 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/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +22 -16
- data/lib/braintree/transaction_gateway.rb +9 -10
- data/lib/braintree/transaction_line_item.rb +2 -2
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +1 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +2 -2
- data/lib/braintree/webhook_notification_gateway.rb +3 -3
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +1 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +2 -2
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +4 -1
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/payment_method_nonce_spec.rb +20 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +72 -0
- data/spec/integration/braintree/transaction_search_spec.rb +27 -0
- data/spec/integration/braintree/transaction_spec.rb +192 -66
- data/spec/unit/braintree/enriched_customer_data_spec.rb +9 -0
- data/spec/unit/braintree/http_spec.rb +1 -1
- 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/transaction_gateway_spec.rb +30 -1
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +5 -0
- data/spec/unit/braintree/venmo_profile_data_spec.rb +11 -0
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbacdc492fa27aed57086131c1feab00ed435923034cae5dd7b5c6d4c3184a1a
|
|
4
|
+
data.tar.gz: a3c9be778fb88ef5a0ea6c23182f74654b511dca659e34529fade077712418ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b6e24f668d3bd022069f5e85ed55afe9fbdce43205af6dd44a101f6aef3f78d2b2099d5b8d5c8297cbf3076dee72da16e61d7b758cb162278190e99d9f95d91
|
|
7
|
+
data.tar.gz: 3ee3af6a1854de4b02db4670b3d32232b2ce7d26ae478bfa792dcc4ccfe638f52259e80e818704d630c8a0b453a1f566062865045f370f5f83a377e0c7083d16
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class AccountUpdaterDailyReport
|
|
2
|
+
class AccountUpdaterDailyReport
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
5
|
attr_reader :report_date
|
|
@@ -7,12 +7,12 @@ module Braintree
|
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
9
|
protected :new
|
|
10
|
-
def _new(*args)
|
|
10
|
+
def _new(*args)
|
|
11
11
|
self.new(*args)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def initialize(attributes)
|
|
15
|
+
def initialize(attributes)
|
|
16
16
|
set_instance_variables_from_hash(attributes)
|
|
17
17
|
@report_date = Date.parse(report_date)
|
|
18
18
|
end
|
data/lib/braintree/address.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class Address
|
|
3
|
-
include BaseModule
|
|
3
|
+
include BaseModule
|
|
4
4
|
|
|
5
5
|
attr_reader :company
|
|
6
6
|
attr_reader :country_code_alpha2
|
|
@@ -44,12 +44,12 @@ module Braintree
|
|
|
44
44
|
Configuration.gateway.address.update!(*args)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def initialize(gateway, attributes)
|
|
47
|
+
def initialize(gateway, attributes)
|
|
48
48
|
@gateway = gateway
|
|
49
49
|
set_instance_variables_from_hash(attributes)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def ==(other)
|
|
52
|
+
def ==(other)
|
|
53
53
|
return false unless other.is_a?(Address)
|
|
54
54
|
id == other.id && customer_id == other.customer_id
|
|
55
55
|
end
|
|
@@ -58,7 +58,7 @@ module Braintree
|
|
|
58
58
|
protected :new
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def self._new(*args)
|
|
61
|
+
def self._new(*args)
|
|
62
62
|
self.new(*args)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class AddressGateway
|
|
2
|
+
class AddressGateway
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
5
|
def initialize(gateway)
|
|
@@ -62,7 +62,7 @@ module Braintree
|
|
|
62
62
|
return_object_or_raise(:address) { update(*args) }
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def _determine_customer_id(customer_or_customer_id)
|
|
65
|
+
def _determine_customer_id(customer_or_customer_id)
|
|
66
66
|
customer_id = customer_or_customer_id.is_a?(Customer) ? customer_or_customer_id.id : customer_or_customer_id
|
|
67
67
|
unless customer_id =~ /\A[\w_-]+\z/
|
|
68
68
|
raise ArgumentError, "customer_id contains invalid characters"
|
|
@@ -70,17 +70,17 @@ module Braintree
|
|
|
70
70
|
customer_id
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
def self._create_signature
|
|
73
|
+
def self._create_signature
|
|
74
74
|
_shared_signature + [:customer_id]
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def self._shared_signature
|
|
77
|
+
def self._shared_signature
|
|
78
78
|
[:company, :country_code_alpha2, :country_code_alpha3, :country_code_numeric,
|
|
79
79
|
:country_name, :extended_address, :first_name, :last_name, :locality, :phone_number,
|
|
80
80
|
:postal_code, :region, :street_address]
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
def self._update_signature
|
|
83
|
+
def self._update_signature
|
|
84
84
|
_create_signature
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class AdvancedSearch
|
|
3
|
-
class SearchNode
|
|
2
|
+
class AdvancedSearch
|
|
3
|
+
class SearchNode
|
|
4
4
|
def self.operators(*operator_names)
|
|
5
5
|
operator_names.each do |operator|
|
|
6
6
|
define_method(operator) do |value|
|
|
@@ -14,29 +14,29 @@ module Braintree
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
class IsNode < SearchNode
|
|
17
|
+
class IsNode < SearchNode
|
|
18
18
|
operators :is
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
class EqualityNode < IsNode
|
|
21
|
+
class EqualityNode < IsNode
|
|
22
22
|
operators :is_not
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
class PartialMatchNode < EqualityNode
|
|
25
|
+
class PartialMatchNode < EqualityNode
|
|
26
26
|
operators :ends_with, :starts_with
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
class TextNode < PartialMatchNode
|
|
29
|
+
class TextNode < PartialMatchNode
|
|
30
30
|
operators :contains
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
class KeyValueNode < SearchNode
|
|
33
|
+
class KeyValueNode < SearchNode
|
|
34
34
|
def is(value)
|
|
35
35
|
@parent.add_criteria(@node_name, value)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
class MultipleValueNode < SearchNode
|
|
39
|
+
class MultipleValueNode < SearchNode
|
|
40
40
|
def in(*values)
|
|
41
41
|
values.flatten!
|
|
42
42
|
|
|
@@ -62,7 +62,7 @@ module Braintree
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
class EndsWithNode < SearchNode
|
|
65
|
+
class EndsWithNode < SearchNode
|
|
66
66
|
operators :ends_with
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -76,7 +76,7 @@ module Braintree
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
class RangeNode < SearchNode
|
|
79
|
+
class RangeNode < SearchNode
|
|
80
80
|
operators :is
|
|
81
81
|
|
|
82
82
|
def between(min, max)
|
data/lib/braintree/apple_pay.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class ApplePay
|
|
3
|
-
include BaseModule
|
|
3
|
+
include BaseModule
|
|
4
4
|
|
|
5
|
-
def initialize(gateway, attributes)
|
|
5
|
+
def initialize(gateway, attributes)
|
|
6
6
|
set_instance_variables_from_hash(attributes)
|
|
7
7
|
end
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ module Braintree
|
|
|
10
10
|
protected :new
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def self._new(*args)
|
|
13
|
+
def self._new(*args)
|
|
14
14
|
self.new(*args)
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class ApplePayCard
|
|
3
|
-
include BaseModule
|
|
3
|
+
include BaseModule
|
|
4
4
|
|
|
5
5
|
module CardType
|
|
6
6
|
AmEx = "Apple Pay - American Express"
|
|
@@ -39,7 +39,7 @@ module Braintree
|
|
|
39
39
|
attr_reader :token
|
|
40
40
|
attr_reader :updated_at
|
|
41
41
|
|
|
42
|
-
def initialize(gateway, attributes)
|
|
42
|
+
def initialize(gateway, attributes)
|
|
43
43
|
@gateway = gateway
|
|
44
44
|
set_instance_variables_from_hash(attributes)
|
|
45
45
|
@billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
|
|
@@ -58,7 +58,7 @@ module Braintree
|
|
|
58
58
|
protected :new
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def self._new(*args)
|
|
61
|
+
def self._new(*args)
|
|
62
62
|
self.new(*args)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class ApplePayOptions
|
|
3
|
-
include BaseModule
|
|
3
|
+
include BaseModule
|
|
4
4
|
|
|
5
5
|
attr_reader :domains
|
|
6
6
|
|
|
7
|
-
def initialize(attributes)
|
|
7
|
+
def initialize(attributes)
|
|
8
8
|
set_instance_variables_from_hash(attributes)
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ module Braintree
|
|
|
12
12
|
protected :new
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self._new(*args)
|
|
15
|
+
def self._new(*args)
|
|
16
16
|
self.new(*args)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class AuthorizationAdjustment
|
|
2
|
+
class AuthorizationAdjustment
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
5
|
attr_reader :amount
|
|
@@ -11,12 +11,12 @@ module Braintree
|
|
|
11
11
|
|
|
12
12
|
class << self
|
|
13
13
|
protected :new
|
|
14
|
-
def _new(*args)
|
|
14
|
+
def _new(*args)
|
|
15
15
|
self.new(*args)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def initialize(attributes)
|
|
19
|
+
def initialize(attributes)
|
|
20
20
|
set_instance_variables_from_hash(attributes)
|
|
21
21
|
end
|
|
22
22
|
end
|
data/lib/braintree/bin_data.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class BinData
|
|
2
|
+
class BinData
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
5
|
attr_reader :commercial
|
|
@@ -23,7 +23,7 @@ module Braintree
|
|
|
23
23
|
"#<#{self.class} #{formatted_attributes.join(", ")}>"
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def self._attributes
|
|
26
|
+
def self._attributes
|
|
27
27
|
[
|
|
28
28
|
:commercial, :country_of_issuance, :debit, :durbin_regulated, :healthcare,
|
|
29
29
|
:issuing_bank, :payroll, :prepaid, :product_id
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class Configuration
|
|
3
|
-
API_VERSION = "6"
|
|
4
|
-
DEFAULT_ENDPOINT = "api"
|
|
5
|
-
|
|
3
|
+
API_VERSION = "6"
|
|
4
|
+
DEFAULT_ENDPOINT = "api"
|
|
5
|
+
# NEXT_MAJOR_VERSION update to the latest version of GraphQL API
|
|
6
|
+
GRAPHQL_API_VERSION = "2018-09-10"
|
|
6
7
|
|
|
7
8
|
READABLE_ATTRIBUTES = [
|
|
8
9
|
:merchant_id,
|
|
@@ -47,18 +48,17 @@ module Braintree
|
|
|
47
48
|
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
|
48
49
|
attr_writer(*WRITABLE_ATTRIBUTES)
|
|
49
50
|
|
|
50
|
-
def self.expectant_reader(*attributes)
|
|
51
|
+
def self.expectant_reader(*attributes)
|
|
51
52
|
attributes.each do |attribute|
|
|
52
53
|
(class << self; self; end).send(:define_method, attribute) do
|
|
53
54
|
attribute_value = instance_variable_get("@#{attribute}")
|
|
54
|
-
raise ConfigurationError.new("Braintree::Configuration.#{attribute
|
|
55
|
+
raise ConfigurationError.new("Braintree::Configuration.#{attribute} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty?
|
|
55
56
|
attribute_value
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
expectant_reader(*READABLE_ATTRIBUTES)
|
|
60
61
|
|
|
61
|
-
# Sets the Braintree environment to use. Valid values are <tt>:sandbox</tt> and <tt>:production</tt>
|
|
62
62
|
def self.environment=(env)
|
|
63
63
|
env = env.to_sym
|
|
64
64
|
unless [:development, :qa, :sandbox, :production].include?(env)
|
|
@@ -67,11 +67,11 @@ module Braintree
|
|
|
67
67
|
@environment = env
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def self.gateway
|
|
70
|
+
def self.gateway
|
|
71
71
|
Braintree::Gateway.new(instantiate)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
def self.instantiate
|
|
74
|
+
def self.instantiate
|
|
75
75
|
config = new(
|
|
76
76
|
:custom_user_agent => @custom_user_agent,
|
|
77
77
|
:endpoint => @endpoint,
|
|
@@ -158,15 +158,15 @@ module Braintree
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
def api_version
|
|
161
|
+
def api_version
|
|
162
162
|
API_VERSION
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
def graphql_api_version
|
|
165
|
+
def graphql_api_version
|
|
166
166
|
GRAPHQL_API_VERSION
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
def base_merchant_path
|
|
169
|
+
def base_merchant_path
|
|
170
170
|
"/merchants/#{merchant_id}"
|
|
171
171
|
end
|
|
172
172
|
|
|
@@ -178,11 +178,11 @@ module Braintree
|
|
|
178
178
|
"#{protocol}://#{graphql_server}:#{graphql_port}/graphql"
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
def base_merchant_url
|
|
181
|
+
def base_merchant_url
|
|
182
182
|
"#{base_url}#{base_merchant_path}"
|
|
183
183
|
end
|
|
184
184
|
|
|
185
|
-
def ca_file
|
|
185
|
+
def ca_file
|
|
186
186
|
File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "api_braintreegateway_com.ca.crt"))
|
|
187
187
|
end
|
|
188
188
|
|
|
@@ -190,7 +190,7 @@ module Braintree
|
|
|
190
190
|
@endpoint || DEFAULT_ENDPOINT
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
-
def http
|
|
193
|
+
def http
|
|
194
194
|
Http.new(self)
|
|
195
195
|
end
|
|
196
196
|
|
|
@@ -202,7 +202,7 @@ module Braintree
|
|
|
202
202
|
@logger ||= self.class._default_logger
|
|
203
203
|
end
|
|
204
204
|
|
|
205
|
-
def port
|
|
205
|
+
def port
|
|
206
206
|
case @environment
|
|
207
207
|
when :development, :integration
|
|
208
208
|
ENV["GATEWAY_PORT"] || 3000
|
|
@@ -211,7 +211,7 @@ module Braintree
|
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
213
|
|
|
214
|
-
def graphql_port
|
|
214
|
+
def graphql_port
|
|
215
215
|
case @environment
|
|
216
216
|
when :development, :integration
|
|
217
217
|
ENV["GRAPHQL_PORT"] || 8080
|
|
@@ -220,7 +220,7 @@ module Braintree
|
|
|
220
220
|
end
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
def protocol
|
|
223
|
+
def protocol
|
|
224
224
|
ssl? ? "https" : "http"
|
|
225
225
|
end
|
|
226
226
|
|
|
@@ -232,7 +232,7 @@ module Braintree
|
|
|
232
232
|
@http_read_timeout
|
|
233
233
|
end
|
|
234
234
|
|
|
235
|
-
def server
|
|
235
|
+
def server
|
|
236
236
|
case @environment
|
|
237
237
|
when :development, :integration
|
|
238
238
|
ENV["GATEWAY_HOST"] || "localhost"
|
|
@@ -245,7 +245,7 @@ module Braintree
|
|
|
245
245
|
end
|
|
246
246
|
end
|
|
247
247
|
|
|
248
|
-
def graphql_server
|
|
248
|
+
def graphql_server
|
|
249
249
|
case @environment
|
|
250
250
|
when :development, :integration
|
|
251
251
|
ENV["GRAPHQL_HOST"] || "graphql.bt.local"
|
|
@@ -271,7 +271,7 @@ module Braintree
|
|
|
271
271
|
end
|
|
272
272
|
end
|
|
273
273
|
|
|
274
|
-
def ssl?
|
|
274
|
+
def ssl?
|
|
275
275
|
case @environment
|
|
276
276
|
when :development, :integration
|
|
277
277
|
false
|
|
@@ -280,12 +280,12 @@ module Braintree
|
|
|
280
280
|
end
|
|
281
281
|
end
|
|
282
282
|
|
|
283
|
-
def user_agent
|
|
283
|
+
def user_agent
|
|
284
284
|
base_user_agent = "Braintree Ruby Gem #{Braintree::Version::String}"
|
|
285
285
|
@custom_user_agent ? "#{base_user_agent} (#{@custom_user_agent})" : base_user_agent
|
|
286
286
|
end
|
|
287
287
|
|
|
288
|
-
def self._default_logger
|
|
288
|
+
def self._default_logger
|
|
289
289
|
logger = Logger.new(STDOUT)
|
|
290
290
|
logger.level = Logger::INFO
|
|
291
291
|
logger
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Braintree
|
|
2
2
|
class CreditCard
|
|
3
|
-
include BaseModule
|
|
3
|
+
include BaseModule
|
|
4
4
|
include Braintree::Util::TokenEquality
|
|
5
5
|
|
|
6
6
|
module CardType
|
|
@@ -25,6 +25,7 @@ module Braintree
|
|
|
25
25
|
|
|
26
26
|
module DebitNetwork
|
|
27
27
|
Accel = "ACCEL"
|
|
28
|
+
Maestro = "MAESTRO"
|
|
28
29
|
Nyce = "NYCE"
|
|
29
30
|
Pulse = "PULSE"
|
|
30
31
|
Star = "STAR"
|
|
@@ -124,7 +125,7 @@ module Braintree
|
|
|
124
125
|
Configuration.gateway.credit_card.update!(*args)
|
|
125
126
|
end
|
|
126
127
|
|
|
127
|
-
def initialize(gateway, attributes)
|
|
128
|
+
def initialize(gateway, attributes)
|
|
128
129
|
@gateway = gateway
|
|
129
130
|
set_instance_variables_from_hash(attributes)
|
|
130
131
|
@billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
|
|
@@ -133,11 +134,10 @@ module Braintree
|
|
|
133
134
|
end
|
|
134
135
|
|
|
135
136
|
def _most_recent_verification(attributes)
|
|
136
|
-
|
|
137
|
-
CreditCardVerification._new(
|
|
137
|
+
sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
|
|
138
|
+
CreditCardVerification._new(sorted_verifications) if sorted_verifications
|
|
138
139
|
end
|
|
139
140
|
|
|
140
|
-
# Returns true if this credit card is the customer's default payment method.
|
|
141
141
|
def default?
|
|
142
142
|
@default
|
|
143
143
|
end
|
|
@@ -147,12 +147,11 @@ module Braintree
|
|
|
147
147
|
"#{expiration_month}/#{expiration_year}"
|
|
148
148
|
end
|
|
149
149
|
|
|
150
|
-
# Returns true if the credit card is expired.
|
|
151
150
|
def expired?
|
|
152
151
|
@expired
|
|
153
152
|
end
|
|
154
153
|
|
|
155
|
-
def inspect
|
|
154
|
+
def inspect
|
|
156
155
|
first = [:token]
|
|
157
156
|
order = first + (self.class._attributes - first)
|
|
158
157
|
nice_attributes = order.map do |attr|
|
|
@@ -169,6 +168,7 @@ module Braintree
|
|
|
169
168
|
@nonce ||= PaymentMethodNonce.create(token)
|
|
170
169
|
end
|
|
171
170
|
|
|
171
|
+
# NEXT_MAJOR_VERSION can this be removed? Venmo SDK integration is no more
|
|
172
172
|
# Returns true if the card is associated with Venmo SDK
|
|
173
173
|
# NEXT_MAJOR_VERSION Remove this method
|
|
174
174
|
# The old venmo SDK class has been deprecated
|
|
@@ -185,7 +185,7 @@ module Braintree
|
|
|
185
185
|
protected :new
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
def self._attributes
|
|
188
|
+
def self._attributes
|
|
189
189
|
[
|
|
190
190
|
:billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
|
|
191
191
|
:expiration_year, :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, :commercial, :debit, :durbin_regulated,
|
|
@@ -193,7 +193,7 @@ module Braintree
|
|
|
193
193
|
]
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
def self._new(*args)
|
|
196
|
+
def self._new(*args)
|
|
197
197
|
self.new(*args)
|
|
198
198
|
end
|
|
199
199
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class CreditCardGateway
|
|
2
|
+
class CreditCardGateway
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
5
|
def initialize(gateway)
|
|
@@ -77,15 +77,15 @@ module Braintree
|
|
|
77
77
|
return_object_or_raise(:credit_card) { update(*args) }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
def self._create_signature
|
|
80
|
+
def self._create_signature
|
|
81
81
|
_signature(:create)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
def self._update_signature
|
|
84
|
+
def self._update_signature
|
|
85
85
|
_signature(:update)
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
def self._signature(type)
|
|
88
|
+
def self._signature(type)
|
|
89
89
|
billing_address_params = AddressGateway._shared_signature
|
|
90
90
|
# NEXT_MAJOR_VERSION Remove venmo_sdk_session
|
|
91
91
|
# The old venmo SDK class has been deprecated
|
|
@@ -136,7 +136,7 @@ module Braintree
|
|
|
136
136
|
return signature
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
def _do_create(path, params=nil)
|
|
139
|
+
def _do_create(path, params=nil)
|
|
140
140
|
response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
|
|
141
141
|
if response[:credit_card]
|
|
142
142
|
SuccessfulResult.new(:credit_card => CreditCard._new(@gateway, response[:credit_card]))
|
|
@@ -147,7 +147,7 @@ module Braintree
|
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
|
|
150
|
-
def _do_update(http_verb, path, params)
|
|
150
|
+
def _do_update(http_verb, path, params)
|
|
151
151
|
response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
|
|
152
152
|
if response[:credit_card]
|
|
153
153
|
SuccessfulResult.new(:credit_card => CreditCard._new(@gateway, response[:credit_card]))
|
|
@@ -158,13 +158,13 @@ module Braintree
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
def _fetch_expired(ids)
|
|
161
|
+
def _fetch_expired(ids)
|
|
162
162
|
response = @config.http.post("#{@config.base_merchant_path}/payment_methods/all/expired", :search => {:ids => ids})
|
|
163
163
|
attributes = response[:payment_methods]
|
|
164
164
|
Util.extract_attribute_as_array(attributes, :credit_card).map { |attrs| CreditCard._new(@gateway, attrs) }
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
-
def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids)
|
|
167
|
+
def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids)
|
|
168
168
|
response = @config.http.post(
|
|
169
169
|
"#{@config.base_merchant_path}/payment_methods/all/expiring?start=#{formatted_start_date}&end=#{formatted_end_date}",
|
|
170
170
|
:search => {:ids => ids},
|
|
@@ -48,7 +48,7 @@ module Braintree
|
|
|
48
48
|
attr_reader :three_d_secure_info
|
|
49
49
|
attr_reader :status
|
|
50
50
|
|
|
51
|
-
def initialize(attributes)
|
|
51
|
+
def initialize(attributes)
|
|
52
52
|
set_instance_variables_from_hash(attributes)
|
|
53
53
|
|
|
54
54
|
@amount = Util.to_big_decimal(amount)
|
|
@@ -57,7 +57,7 @@ module Braintree
|
|
|
57
57
|
@three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info]
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
def inspect
|
|
60
|
+
def inspect
|
|
61
61
|
attr_order = [
|
|
62
62
|
:status,
|
|
63
63
|
:processor_response_code,
|
|
@@ -91,7 +91,7 @@ module Braintree
|
|
|
91
91
|
protected :new
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
def self._new(*args)
|
|
94
|
+
def self._new(*args)
|
|
95
95
|
self.new(*args)
|
|
96
96
|
end
|
|
97
97
|
|