braintree 4.24.0 → 4.26.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/apple_pay_card.rb +1 -0
- data/lib/braintree/bin_data.rb +2 -1
- data/lib/braintree/credit_card.rb +6 -5
- data/lib/braintree/customer_session_gateway.rb +194 -0
- data/lib/braintree/error_codes.rb +41 -0
- data/lib/braintree/error_result.rb +1 -1
- data/lib/braintree/errors.rb +2 -1
- data/lib/braintree/gateway.rb +8 -0
- data/lib/braintree/google_pay_card.rb +1 -0
- data/lib/braintree/graphql/enums/recommendations.rb +7 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +8 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +35 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +41 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +39 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +32 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +37 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +32 -0
- data/lib/braintree/graphql/types/payment_options.rb +33 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +34 -0
- data/lib/braintree/graphql_client.rb +16 -0
- data/lib/braintree/meta_checkout_card.rb +6 -5
- data/lib/braintree/meta_checkout_token.rb +6 -5
- data/lib/braintree/paypal_payment_resource.rb +22 -0
- data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
- data/lib/braintree/successful_result.rb +2 -0
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/transaction/apple_pay_details.rb +1 -0
- data/lib/braintree/transaction/credit_card_details.rb +12 -10
- data/lib/braintree/transaction/google_pay_details.rb +11 -10
- data/lib/braintree/transaction/meta_checkout_card_details.rb +5 -2
- data/lib/braintree/transaction/meta_checkout_token_details.rb +6 -2
- data/lib/braintree/transaction/visa_checkout_card_details.rb +5 -2
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +5 -5
- data/lib/braintree.rb +13 -0
- data/spec/integration/braintree/credit_card_spec.rb +12 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +24 -0
- data/spec/integration/braintree/customer_session_spec.rb +143 -0
- data/spec/integration/braintree/customer_spec.rb +22 -6
- data/spec/integration/braintree/payment_method_nonce_spec.rb +11 -0
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/transaction_spec.rb +15 -0
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -0
- data/spec/unit/braintree/credit_card_spec.rb +5 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +120 -0
- data/spec/unit/braintree/google_pay_card_spec.rb +8 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +110 -0
- data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +93 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +53 -51
- data/spec/unit/braintree/meta_checkout_token_spec.rb +3 -1
- data/spec/unit/braintree/payment_method_nonce_spec.rb +4 -1
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +2 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction_spec.rb +2 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +8 -0
- data/spec/unit/credit_card_details_spec.rb +8 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca8e969e0988757df5800a440fdc36293b48bc0c72cc8c56b1175d74d79f309b
|
4
|
+
data.tar.gz: b44530a7eb4a73728fd4c79292633fc7d7ca0d6476c26b7277c1a3051d29fcaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d985f754fa864774601dad717587b5d5d7f1e75a9579286100559e9cd4ab1819fd856b5c90c6d59870149b6d7bfd0cc5d2865f2d96362a208c037854b9ab312
|
7
|
+
data.tar.gz: 2ab4e8c0f48d76e10f4854e3e32fe55c154c8bdd40730625409f4259921268788c9bd2baf3152724a6d665ed5d0bf53dc7b540570f2f9777ced5dc53be6aeaa8
|
data/lib/braintree/bin_data.rb
CHANGED
@@ -10,6 +10,7 @@ module Braintree
|
|
10
10
|
attr_reader :issuing_bank
|
11
11
|
attr_reader :payroll
|
12
12
|
attr_reader :prepaid
|
13
|
+
attr_reader :prepaid_reloadable
|
13
14
|
attr_reader :product_id
|
14
15
|
|
15
16
|
def initialize(attributes)
|
@@ -26,7 +27,7 @@ module Braintree
|
|
26
27
|
def self._attributes
|
27
28
|
[
|
28
29
|
:commercial, :country_of_issuance, :debit, :durbin_regulated, :healthcare,
|
29
|
-
:issuing_bank, :payroll, :prepaid, :product_id
|
30
|
+
:issuing_bank, :payroll, :prepaid, :prepaid_reloadable, :product_id
|
30
31
|
]
|
31
32
|
end
|
32
33
|
end
|
@@ -45,8 +45,8 @@ module Braintree
|
|
45
45
|
Unknown = "Unknown"
|
46
46
|
end
|
47
47
|
|
48
|
-
Commercial = Debit = DurbinRegulated = Healthcare =
|
49
|
-
IssuingBank =
|
48
|
+
Commercial = CountryOfIssuance = Debit = DurbinRegulated = Healthcare =
|
49
|
+
IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = CardTypeIndicator
|
50
50
|
|
51
51
|
attr_reader :billing_address
|
52
52
|
attr_reader :bin
|
@@ -66,6 +66,7 @@ module Braintree
|
|
66
66
|
attr_reader :last_4
|
67
67
|
attr_reader :payroll
|
68
68
|
attr_reader :prepaid
|
69
|
+
attr_reader :prepaid_reloadable
|
69
70
|
attr_reader :product_id
|
70
71
|
attr_reader :subscriptions
|
71
72
|
attr_reader :token
|
@@ -199,9 +200,9 @@ module Braintree
|
|
199
200
|
|
200
201
|
def self._attributes
|
201
202
|
[
|
202
|
-
:billing_address, :bin, :card_type, :cardholder_name, :
|
203
|
-
:
|
204
|
-
:
|
203
|
+
:billing_address, :bin, :card_type, :cardholder_name, :commercial, :country_of_issuance, :created_at, :customer_id,
|
204
|
+
:debit, :durbin_regulated, :expiration_month, :expiration_year, :healthcare, :image_url, :is_network_tokenized?,
|
205
|
+
:issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable, :product_id, :token, :updated_at
|
205
206
|
]
|
206
207
|
end
|
207
208
|
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# Creates and manages PayPal customer sessions.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CustomerSessionGateway
|
5
|
+
CREATE_CUSTOMER_SESSION = <<~GRAPHQL
|
6
|
+
mutation CreateCustomerSession($input: CreateCustomerSessionInput!) {
|
7
|
+
createCustomerSession(input: $input) {
|
8
|
+
sessionId
|
9
|
+
}
|
10
|
+
}
|
11
|
+
GRAPHQL
|
12
|
+
|
13
|
+
UPDATE_CUSTOMER_SESSION = <<~GRAPHQL
|
14
|
+
mutation UpdateCustomerSession($input: UpdateCustomerSessionInput!) {
|
15
|
+
updateCustomerSession(input: $input) {
|
16
|
+
sessionId
|
17
|
+
}
|
18
|
+
}
|
19
|
+
GRAPHQL
|
20
|
+
|
21
|
+
GET_CUSTOMER_RECOMMENDATIONS = <<~GRAPHQL
|
22
|
+
query CustomerRecommendations($input: CustomerRecommendationsInput!) {
|
23
|
+
customerRecommendations(input: $input) {
|
24
|
+
isInPayPalNetwork
|
25
|
+
recommendations {
|
26
|
+
... on PaymentRecommendations {
|
27
|
+
paymentOptions {
|
28
|
+
paymentOption
|
29
|
+
recommendedPriority
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
GRAPHQL
|
36
|
+
|
37
|
+
def initialize(gateway, graphql_client)
|
38
|
+
@gateway = gateway
|
39
|
+
@graphql_client = graphql_client
|
40
|
+
end
|
41
|
+
|
42
|
+
# Creates a new customer session.
|
43
|
+
#
|
44
|
+
# Example:
|
45
|
+
# customer = {
|
46
|
+
# email: "test@example.com",
|
47
|
+
# device_fingerprint_id: "1234",
|
48
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
49
|
+
# paypal_app_installed: true,
|
50
|
+
# venmo_app_installed: true,
|
51
|
+
# }
|
52
|
+
# input = Braintree::CreateCustomerSessionInput.new(
|
53
|
+
# customer: customer,
|
54
|
+
# )
|
55
|
+
# result = gateway.customer_session.create_customer_session(input)
|
56
|
+
# if result.success?
|
57
|
+
# puts "Created session #{result.session_id}"
|
58
|
+
# else
|
59
|
+
# puts "Validations failed"
|
60
|
+
# puts result.errors.first.message
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# @param input [CreateCustomerSessionInput] The input parameters for creating a customer session.
|
64
|
+
#
|
65
|
+
# @return [(Successful|Error)Result] A result object with session ID if successful, or errors otherwise.
|
66
|
+
#
|
67
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
68
|
+
def create_customer_session(input)
|
69
|
+
execute_mutation(CREATE_CUSTOMER_SESSION, input, :createCustomerSession)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
# Updates an existing customer session.
|
74
|
+
#
|
75
|
+
# Example:
|
76
|
+
# customer = {
|
77
|
+
# email: "test@example.com",
|
78
|
+
# device_fingerprint_id: "1234",
|
79
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
80
|
+
# paypal_app_installed: true,
|
81
|
+
# venmo_app_installed: true,
|
82
|
+
# }
|
83
|
+
# input = Braintree::UpdateCustomerSessionInput.new(
|
84
|
+
# session_id: "11EF-34BC-2702904B-9026-555555555555",
|
85
|
+
# customer: customer,
|
86
|
+
# )
|
87
|
+
# result = gateway.customer_session.updated_customer_session(input)
|
88
|
+
# if result.success?
|
89
|
+
# puts "Updated session #{result.session_id}"
|
90
|
+
# else
|
91
|
+
# puts "Validations failed"
|
92
|
+
# puts result.errors.first.message
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# @param input [UpdateCustomerSessionInput] The input parameters for updating a customer session.
|
96
|
+
#
|
97
|
+
# @return [(Successful|Error)Result] A result object with session ID if successful, or errors otherwise.
|
98
|
+
#
|
99
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
100
|
+
def update_customer_session(input)
|
101
|
+
execute_mutation(UPDATE_CUSTOMER_SESSION, input, :updateCustomerSession)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Retrieves customer recommendations associated with a customer session.
|
105
|
+
#
|
106
|
+
# Example:
|
107
|
+
# customer = {
|
108
|
+
# email: "test@example.com",
|
109
|
+
# device_fingerprint_id: "1234",
|
110
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
111
|
+
# paypal_app_installed: true,
|
112
|
+
# venmo_app_installed: true,
|
113
|
+
# }
|
114
|
+
# input = Braintree::CustomerRecommendationsInput.new(
|
115
|
+
# session_id: "11EF-34BC-2702904B-9026-555555555555",
|
116
|
+
# customer: customer,
|
117
|
+
# recommendations: [Braintree::Recommendations::PAYMENT_RECOMMENDATIONS]
|
118
|
+
# )
|
119
|
+
# result = gateway.customer_session.get_customer_recommendations(input)
|
120
|
+
# if result.success?
|
121
|
+
# puts "Fetched customer recommendations"
|
122
|
+
# payload = result.customer_recommendations
|
123
|
+
# puts payload
|
124
|
+
# else
|
125
|
+
# puts "Validations failed"
|
126
|
+
# puts result.errors.first.message
|
127
|
+
# end
|
128
|
+
#
|
129
|
+
# @param input [CustomerRecommendationsInput] The input parameters for retrieving customer recommendations.
|
130
|
+
#
|
131
|
+
# @return [Result\Error|Result\Successful] A result object containing the customer recommendations if successful, or errors otherwise.
|
132
|
+
#
|
133
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
134
|
+
def get_customer_recommendations(customer_recommendations_input)
|
135
|
+
variables = {"input" => customer_recommendations_input.to_graphql_variables}
|
136
|
+
|
137
|
+
begin
|
138
|
+
response = @graphql_client.query(GET_CUSTOMER_RECOMMENDATIONS, variables)
|
139
|
+
errors = GraphQLClient.get_validation_errors(response)
|
140
|
+
if errors
|
141
|
+
ErrorResult.new(@gateway, {errors:errors})
|
142
|
+
else
|
143
|
+
SuccessfulResult.new(:customer_recommendations => extract_customer_recommendations_payload(response))
|
144
|
+
end
|
145
|
+
rescue StandardError => e
|
146
|
+
raise UnexpectedError, e.message
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
def execute_mutation(query, input, operation_name)
|
153
|
+
variables = {"input" => input.to_graphql_variables}
|
154
|
+
begin
|
155
|
+
response = @graphql_client.query(query, variables)
|
156
|
+
errors = GraphQLClient.get_validation_errors(response)
|
157
|
+
if errors
|
158
|
+
ErrorResult.new(@gateway, {errors:errors})
|
159
|
+
else
|
160
|
+
session_id = get_value(response, "data.#{operation_name}.sessionId")
|
161
|
+
SuccessfulResult.new(:session_id => session_id)
|
162
|
+
end
|
163
|
+
rescue StandardError => e
|
164
|
+
raise UnexpectedError, e.message
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_value(response, key)
|
169
|
+
map = response
|
170
|
+
key_parts = key.split(".")
|
171
|
+
|
172
|
+
key_parts[0..-2].each do |sub_key|
|
173
|
+
map = pop_value(map, sub_key)
|
174
|
+
raise UnexpectedError, "Couldn't parse response" unless map.is_a?(Hash)
|
175
|
+
end
|
176
|
+
|
177
|
+
pop_value(map, key_parts.last)
|
178
|
+
end
|
179
|
+
|
180
|
+
def pop_value(map, key)
|
181
|
+
key = key.to_sym
|
182
|
+
if map.key?(key)
|
183
|
+
map[key]
|
184
|
+
else
|
185
|
+
raise UnexpectedError, "Couldn't parse response"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def extract_customer_recommendations_payload(data)
|
190
|
+
customer_recommendations_hash = get_value(data, "data.customerRecommendations")
|
191
|
+
Braintree::CustomerRecommendationsPayload._new(customer_recommendations_hash)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -210,6 +210,47 @@ module Braintree
|
|
210
210
|
TokenIsInUse = "92906"
|
211
211
|
end
|
212
212
|
|
213
|
+
module PayPalPaymentResource
|
214
|
+
NonceExpired = "97301"
|
215
|
+
IdNotSupported = "97302"
|
216
|
+
NonceRequired = "97303"
|
217
|
+
InvalidEmail = "97304"
|
218
|
+
EmailTooLong = "97305"
|
219
|
+
ExpectedLineItemCollection = "97306"
|
220
|
+
ExpectedLineItemHash = "97307"
|
221
|
+
ExpectedLineItemDebit = "97308"
|
222
|
+
InvalidUnitAmount = "97309"
|
223
|
+
InvalidUnitTaxAmount = "97310"
|
224
|
+
IsoCodeRequired = "97311"
|
225
|
+
IsoCodeUnsupported = "97312"
|
226
|
+
ShippingFieldsMissing = "97313"
|
227
|
+
InvalidAmountBreakdown = "97314"
|
228
|
+
ExpectedShippingOptionCollection = "97315"
|
229
|
+
ShippingOptionsRequired = "97316"
|
230
|
+
ShippingOptionFieldsMissing = "97317"
|
231
|
+
InvalidShippingOptionType = "97318"
|
232
|
+
ShippingOptionIdReused = "97319"
|
233
|
+
TooManyShippingOptionsSelected = "97320"
|
234
|
+
ShippingOptionMustMatchBreakdown = "97321"
|
235
|
+
LineItemsShouldMatchTotal = "97322"
|
236
|
+
LineItemsTaxShouldMatchTotal = "97323"
|
237
|
+
PatchCallFailed = "97324"
|
238
|
+
InvalidAmount = "97325"
|
239
|
+
ShippingIdTooLong = "97326"
|
240
|
+
ShippingLabelTooLong = "97327"
|
241
|
+
ShippingFullNameTooLong = "97328"
|
242
|
+
ShippingAddressTooLong = "97329"
|
243
|
+
ShippingExtendedAddressTooLong = "97330"
|
244
|
+
ShippingLocalityTooLong = "97331"
|
245
|
+
ShippingRegionTooLong = "97332"
|
246
|
+
CountryCodeTooLong = "97333"
|
247
|
+
NationalNumberTooLong = "97334"
|
248
|
+
PostalCodeTooLong = "97335"
|
249
|
+
DescriptionTooLong = "97336"
|
250
|
+
CustomFieldTooLong = "97337"
|
251
|
+
OrderIdTooLong = "97338"
|
252
|
+
end
|
253
|
+
|
213
254
|
module SepaDirectDebitAccount
|
214
255
|
SepaDebitAccountPaymentMethodMandateTypeIsNotSupported = "87115"
|
215
256
|
SepaDebitAccountPaymentMethodCustomerIdIsInvalid = "87116"
|
@@ -12,7 +12,7 @@ module Braintree
|
|
12
12
|
|
13
13
|
def initialize(gateway, data)
|
14
14
|
@gateway = gateway
|
15
|
-
@params = data[:params]
|
15
|
+
@params = data[:params] if data[:params]
|
16
16
|
@credit_card_verification = CreditCardVerification._new(data[:verification]) if data[:verification]
|
17
17
|
@merchant_account = MerchantAccount._new(gateway, data[:merchant_account]) if data[:merchant_account]
|
18
18
|
@message = data[:message]
|
data/lib/braintree/errors.rb
CHANGED
data/lib/braintree/gateway.rb
CHANGED
@@ -38,6 +38,10 @@ module Braintree
|
|
38
38
|
CustomerGateway.new(self)
|
39
39
|
end
|
40
40
|
|
41
|
+
def customer_session
|
42
|
+
CustomerSessionGateway.new(self, graphql_client)
|
43
|
+
end
|
44
|
+
|
41
45
|
def discount
|
42
46
|
DiscountGateway.new(self)
|
43
47
|
end
|
@@ -74,6 +78,10 @@ module Braintree
|
|
74
78
|
PayPalAccountGateway.new(self)
|
75
79
|
end
|
76
80
|
|
81
|
+
def paypal_payment_resource
|
82
|
+
PayPalPaymentResourceGateway.new(self)
|
83
|
+
end
|
84
|
+
|
77
85
|
def us_bank_account
|
78
86
|
UsBankAccountGateway.new(self)
|
79
87
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Represents the input to request the creation of a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CreateCustomerSessionInput
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :merchant_account_id
|
9
|
+
attr_reader :session_id
|
10
|
+
attr_reader :customer
|
11
|
+
attr_reader :domain
|
12
|
+
|
13
|
+
def initialize(attributes)
|
14
|
+
@attrs = attributes.keys
|
15
|
+
set_instance_variables_from_hash(attributes)
|
16
|
+
@customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def inspect
|
20
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
21
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_graphql_variables
|
25
|
+
variables = {}
|
26
|
+
variables["merchantAccountId"] = merchant_account_id if merchant_account_id
|
27
|
+
variables["sessionId"] = session_id if session_id
|
28
|
+
variables["domain"] = domain if domain
|
29
|
+
variables["customer"] = customer.to_graphql_variables if customer
|
30
|
+
variables
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Represents the input to request PayPal customer session recommendations.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CustomerRecommendationsInput
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :merchant_account_id
|
9
|
+
attr_reader :session_id
|
10
|
+
attr_reader :recommendations
|
11
|
+
attr_reader :customer
|
12
|
+
|
13
|
+
def initialize(attributes)
|
14
|
+
unless attributes[:session_id]
|
15
|
+
raise ArgumentError, "Expected hash to contain a :session_id"
|
16
|
+
end
|
17
|
+
unless attributes[:recommendations]
|
18
|
+
raise ArgumentError, "Expected hash to contain a :recommendations"
|
19
|
+
end
|
20
|
+
@attrs = attributes.keys
|
21
|
+
set_instance_variables_from_hash(attributes)
|
22
|
+
@customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def inspect
|
26
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
27
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_graphql_variables
|
31
|
+
variables = {}
|
32
|
+
variables["merchantAccountId"] = merchant_account_id if merchant_account_id
|
33
|
+
variables["sessionId"] = session_id if session_id
|
34
|
+
variables["recommendations"] = recommendations if recommendations
|
35
|
+
variables["customer"] = customer.to_graphql_variables if customer
|
36
|
+
variables
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Customer identifying information for a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CustomerSessionInput
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :email
|
9
|
+
attr_reader :phone
|
10
|
+
attr_reader :device_fingerprint_id
|
11
|
+
attr_reader :paypal_app_installed
|
12
|
+
attr_reader :venmo_app_installed
|
13
|
+
attr_reader :user_agent
|
14
|
+
|
15
|
+
def initialize(attributes)
|
16
|
+
@attrs = attributes.keys
|
17
|
+
set_instance_variables_from_hash(attributes)
|
18
|
+
@phone = attributes[:phone] ? PhoneInput.new(attributes[:phone]) : nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspect
|
22
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
23
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_graphql_variables
|
27
|
+
variables = {}
|
28
|
+
variables["email"] = email if email
|
29
|
+
variables["phone"] = phone.to_graphql_variables if phone
|
30
|
+
variables["deviceFingerprintId"] = device_fingerprint_id if device_fingerprint_id
|
31
|
+
variables["paypalAppInstalled"] = paypal_app_installed if paypal_app_installed
|
32
|
+
variables["venmoAppInstalled"] = venmo_app_installed if venmo_app_installed
|
33
|
+
variables["userAgent"] = user_agent if user_agent
|
34
|
+
variables
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Phone number input for PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class PhoneInput
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :country_phone_code
|
9
|
+
attr_reader :phone_number
|
10
|
+
attr_reader :extension_number
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
@attrs = attributes.keys
|
14
|
+
set_instance_variables_from_hash(attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
19
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_graphql_variables
|
23
|
+
variables = {}
|
24
|
+
variables["countryPhoneCode"] = country_phone_code if country_phone_code
|
25
|
+
variables["phoneNumber"] = phone_number if phone_number
|
26
|
+
variables["extensionNumber"] = extension_number if extension_number
|
27
|
+
variables
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Represents the input to request an update to a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class UpdateCustomerSessionInput
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :merchant_account_id
|
9
|
+
attr_reader :session_id
|
10
|
+
attr_reader :customer
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
unless attributes[:session_id]
|
14
|
+
raise ArgumentError, "Expected hash to contain a :session_id"
|
15
|
+
end
|
16
|
+
@attrs = attributes.keys
|
17
|
+
set_instance_variables_from_hash(attributes)
|
18
|
+
@customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspect
|
22
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
23
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_graphql_variables
|
27
|
+
variables = {}
|
28
|
+
variables["merchantAccountId"] = merchant_account_id if merchant_account_id
|
29
|
+
variables["sessionId"] = session_id if session_id
|
30
|
+
variables["customer"] = customer.to_graphql_variables if customer
|
31
|
+
variables
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Represents the customer recommendations information associated with a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CustomerRecommendationsPayload
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :is_in_paypal_network
|
9
|
+
attr_reader :recommendations
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
@attrs = [:is_in_paypal_network, :recommendations]
|
13
|
+
@is_in_paypal_network = attributes[:isInPayPalNetwork] if attributes[:isInPayPalNetwork]
|
14
|
+
@recommendations = CustomerRecommendations._new(attributes[:recommendations]) if attributes[:recommendations]
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
19
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
protected :new
|
24
|
+
end
|
25
|
+
|
26
|
+
def self._new(*args)
|
27
|
+
self.new(*args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Represents the payment method and priority associated with a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class PaymentOptions
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :payment_option
|
9
|
+
attr_reader :recommended_priority
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
@attrs = [:payment_option, :recommended_priority]
|
13
|
+
@payment_option = attributes[:paymentOption] if attributes[:paymentOption]
|
14
|
+
@recommended_priority = attributes[:recommendedPriority] if attributes[:recommendedPriority]
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
20
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
protected :new
|
25
|
+
end
|
26
|
+
|
27
|
+
def self._new(*args)
|
28
|
+
self.new(*args)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# A union of all possible customer recommendations associated with a PayPal customer session.
|
2
|
+
|
3
|
+
module Braintree
|
4
|
+
class CustomerRecommendations
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
attr_reader :attrs
|
8
|
+
attr_reader :payment_options
|
9
|
+
|
10
|
+
def initialize(attributes)
|
11
|
+
@attrs = [:payment_options]
|
12
|
+
if attributes.nil?
|
13
|
+
@payment_options = []
|
14
|
+
else
|
15
|
+
@payment_options = (attributes[:paymentOptions] || []).map { |payment_options_hash| PaymentOptions._new(payment_options_hash) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def inspect
|
20
|
+
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
|
21
|
+
"#<#{self.class} #{inspected_attributes.join(" ")}>"
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
protected :new
|
26
|
+
end
|
27
|
+
|
28
|
+
def self._new(*args)
|
29
|
+
self.new(*args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|