braintree 4.23.0 → 4.34.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/address_gateway.rb +5 -0
- data/lib/braintree/apple_pay_card.rb +6 -0
- data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
- data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
- data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
- data/lib/braintree/bin_data.rb +8 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +12 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +5 -2
- data/lib/braintree/customer_session_gateway.rb +195 -0
- data/lib/braintree/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +58 -104
- data/lib/braintree/error_result.rb +1 -1
- data/lib/braintree/errors.rb +2 -1
- data/lib/braintree/gateway.rb +12 -0
- data/lib/braintree/google_pay_card.rb +5 -0
- data/lib/braintree/graphql/enums/recommendations.rb +9 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
- data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
- data/lib/braintree/graphql/types/payment_options.rb +35 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
- data/lib/braintree/graphql_client.rb +16 -0
- data/lib/braintree/merchant_account.rb +1 -25
- data/lib/braintree/merchant_account_gateway.rb +0 -81
- data/lib/braintree/meta_checkout_card.rb +11 -6
- data/lib/braintree/meta_checkout_token.rb +11 -6
- data/lib/braintree/payment_method_gateway.rb +9 -0
- 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 +3 -0
- data/lib/braintree/test/credit_card.rb +5 -0
- data/lib/braintree/transaction/apple_pay_details.rb +7 -0
- data/lib/braintree/transaction/credit_card_details.rb +22 -10
- data/lib/braintree/transaction/google_pay_details.rb +16 -10
- data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
- data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
- data/lib/braintree/transaction/paypal_details.rb +2 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
- data/lib/braintree/transaction.rb +3 -26
- data/lib/braintree/transaction_gateway.rb +52 -31
- data/lib/braintree/us_bank_account_verification.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +10 -5
- data/lib/braintree/webhook_notification.rb +1 -4
- data/lib/braintree/webhook_testing_gateway.rb +16 -33
- data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
- data/lib/braintree/xml/parser.rb +4 -4
- data/lib/braintree.rb +21 -4
- data/spec/integration/braintree/advanced_search_spec.rb +7 -4
- data/spec/integration/braintree/apple_pay_spec.rb +6 -7
- data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
- data/spec/integration/braintree/credit_card_spec.rb +115 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
- data/spec/integration/braintree/customer_session_spec.rb +154 -0
- data/spec/integration/braintree/customer_spec.rb +94 -10
- data/spec/integration/braintree/disbursement_spec.rb +1 -1
- data/spec/integration/braintree/dispute_spec.rb +13 -2
- data/spec/integration/braintree/merchant_account_spec.rb +19 -359
- data/spec/integration/braintree/merchant_spec.rb +4 -4
- data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
- data/spec/integration/braintree/payment_method_spec.rb +57 -7
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
- data/spec/integration/braintree/transaction_search_spec.rb +38 -33
- data/spec/integration/braintree/transaction_spec.rb +266 -350
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
- data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
- data/spec/spec_helper.rb +46 -12
- data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
- data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
- data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
- data/spec/unit/braintree/client_token_spec.rb +11 -0
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +27 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/dispute_spec.rb +6 -0
- data/spec/unit/braintree/error_result_spec.rb +28 -0
- data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -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 +107 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
- data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
- data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
- data/spec/unit/braintree/transaction_spec.rb +66 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
- data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
- data/spec/unit/braintree/xml/parser_spec.rb +57 -0
- data/spec/unit/credit_card_details_spec.rb +28 -0
- metadata +49 -10
- data/lib/braintree/merchant_account/business_details.rb +0 -17
- data/lib/braintree/merchant_account/funding_details.rb +0 -18
- data/lib/braintree/merchant_account/individual_details.rb +0 -20
- data/lib/ssl/securetrust_ca.crt +0 -44
- data/spec/unit/braintree/disbursement_spec.rb +0 -131
- data/spec/unit/braintree/merchant_account_spec.rb +0 -33
|
@@ -33,5 +33,16 @@ module Braintree
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
describe "error response handling" do
|
|
38
|
+
it "correctly parses error response with nested structure" do
|
|
39
|
+
error_xml = "<api-error-response><message>Invalid request</message><errors><errors type=\"array\"></errors></errors></api-error-response>"
|
|
40
|
+
result = Braintree::Xml::Parser.hash_from_xml(error_xml)
|
|
41
|
+
|
|
42
|
+
expect(result[:api_error_response]).to be_a(Hash)
|
|
43
|
+
expect(result[:api_error_response][:message]).to eq("Invalid request")
|
|
44
|
+
expect(result[:api_error_response][:errors]).to be_a(Hash)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
36
47
|
end
|
|
37
48
|
end
|
|
@@ -399,7 +399,7 @@ describe Braintree::Configuration do
|
|
|
399
399
|
|
|
400
400
|
it "is qa.braintreegateway.com for qa" do
|
|
401
401
|
Braintree::Configuration.environment = :qa
|
|
402
|
-
expect(Braintree::Configuration.instantiate.server).to eq("gateway.
|
|
402
|
+
expect(Braintree::Configuration.instantiate.server).to eq("gateway.qa.braintreepayments.com")
|
|
403
403
|
end
|
|
404
404
|
|
|
405
405
|
it "can by changed by configuring the production endpoint" do
|
|
@@ -25,7 +25,7 @@ describe Braintree::CreditCard do
|
|
|
25
25
|
:payment_method_nonce,
|
|
26
26
|
{:external_vault=>[:network_transaction_id]},
|
|
27
27
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
|
28
|
-
:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
|
28
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
|
29
29
|
{:billing_address => [
|
|
30
30
|
:company,
|
|
31
31
|
:country_code_alpha2,
|
|
@@ -73,7 +73,7 @@ describe Braintree::CreditCard do
|
|
|
73
73
|
:payment_method_nonce,
|
|
74
74
|
{:external_vault=>[:network_transaction_id]},
|
|
75
75
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
|
76
|
-
:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
|
76
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
|
|
77
77
|
{:billing_address => [
|
|
78
78
|
:company,
|
|
79
79
|
:country_code_alpha2,
|
|
@@ -266,4 +266,29 @@ describe Braintree::CreditCard do
|
|
|
266
266
|
end
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
|
+
|
|
270
|
+
it "initializes prepaid reloadable correctly" do
|
|
271
|
+
card = Braintree::CreditCard._new(:gateway, {:prepaid_reloadable => "No"})
|
|
272
|
+
expect(card.prepaid_reloadable).to eq("No")
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "initializes business correctly" do
|
|
276
|
+
card = Braintree::CreditCard._new(:gateway, {:business => "No"})
|
|
277
|
+
expect(card.business).to eq("No")
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
it "initializes consumer correctly" do
|
|
281
|
+
card = Braintree::CreditCard._new(:gateway, {:consumer => "No"})
|
|
282
|
+
expect(card.consumer).to eq("No")
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it "initializes corporate correctly" do
|
|
286
|
+
card = Braintree::CreditCard._new(:gateway, {:corporate => "No"})
|
|
287
|
+
expect(card.corporate).to eq("No")
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it "initializes purchase correctly" do
|
|
291
|
+
card = Braintree::CreditCard._new(:gateway, {:purchase => "No"})
|
|
292
|
+
expect(card.purchase).to eq("No")
|
|
293
|
+
end
|
|
269
294
|
end
|
|
@@ -34,6 +34,7 @@ describe Braintree::CreditCardVerificationGateway do
|
|
|
34
34
|
expect(result.inspect).to include("status")
|
|
35
35
|
expect(result.inspect).to include("intended_transaction_source")
|
|
36
36
|
expect(result.inspect).to include("options")
|
|
37
|
+
expect(result.inspect).to include("account_information_inquiry")
|
|
37
38
|
expect(result.inspect).to include("account_type")
|
|
38
39
|
expect(result.inspect).to include("amount")
|
|
39
40
|
expect(result.inspect).to include("merchant_account_id")
|
|
@@ -159,4 +159,21 @@ describe Braintree::CreditCardVerification do
|
|
|
159
159
|
expect(verification.network_response_text).to eq("Successful approval/completion or V.I.P. PIN verification is successful")
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
|
+
|
|
163
|
+
describe "credit_card with payment_account_reference" do
|
|
164
|
+
it "includes payment_account_reference in credit_card hash when present" do
|
|
165
|
+
verification = Braintree::CreditCardVerification._new(
|
|
166
|
+
:status => "verified",
|
|
167
|
+
:credit_card => {
|
|
168
|
+
:bin => "401288",
|
|
169
|
+
:last_4 => "1881",
|
|
170
|
+
:card_type => "Visa",
|
|
171
|
+
:payment_account_reference => "V0010013019339005665779448477"
|
|
172
|
+
},
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
expect(verification.credit_card).to be_a(Hash)
|
|
176
|
+
expect(verification.credit_card[:payment_account_reference]).to eq("V0010013019339005665779448477")
|
|
177
|
+
end
|
|
178
|
+
end
|
|
162
179
|
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::CustomerSessionGateway do
|
|
4
|
+
let(:gateway) { double(:gateway) }
|
|
5
|
+
let(:graphql_client) { double(:graphql_client) }
|
|
6
|
+
let(:customer_session_gateway) { Braintree::CustomerSessionGateway.new(gateway, graphql_client) }
|
|
7
|
+
|
|
8
|
+
describe "#create_customer_session" do
|
|
9
|
+
let(:input) do
|
|
10
|
+
{
|
|
11
|
+
:merchant_account_id => "merchant-account-id",
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:response) do
|
|
16
|
+
{
|
|
17
|
+
data: {
|
|
18
|
+
createCustomerSession: {
|
|
19
|
+
sessionId: "session-id"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
it "executes the createCustomerSession mutation" do
|
|
27
|
+
create_input = Braintree::CreateCustomerSessionInput.new(input)
|
|
28
|
+
expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::CREATE_CUSTOMER_SESSION,
|
|
29
|
+
{
|
|
30
|
+
"input" => create_input.to_graphql_variables
|
|
31
|
+
}).and_return(response)
|
|
32
|
+
|
|
33
|
+
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
|
|
34
|
+
result = customer_session_gateway.create_customer_session(create_input)
|
|
35
|
+
expect(result).to be_a(Braintree::SuccessfulResult)
|
|
36
|
+
expect(result.session_id).to eq("session-id")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "returns an error result if there are validation errors" do
|
|
40
|
+
create_input = Braintree::CreateCustomerSessionInput.new(input)
|
|
41
|
+
errors = {:errors =>
|
|
42
|
+
[ {:attribute => "", :code => "123", :message => "error"} ]
|
|
43
|
+
}
|
|
44
|
+
expect(graphql_client).to receive(:query).and_return(response)
|
|
45
|
+
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(errors)
|
|
46
|
+
result = customer_session_gateway.create_customer_session(create_input)
|
|
47
|
+
expect(result).to be_a(Braintree::ErrorResult)
|
|
48
|
+
expect(result.errors.first.message).to eq("error")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "raises an UnexpectedError if there is a problem parsing the response" do
|
|
52
|
+
create_input = Braintree::CreateCustomerSessionInput.new(input)
|
|
53
|
+
badResonse = {:data => {}}
|
|
54
|
+
expect(graphql_client).to receive(:query).and_return(badResonse)
|
|
55
|
+
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(badResonse).and_return(nil)
|
|
56
|
+
expect { customer_session_gateway.create_customer_session(create_input) }.to raise_error(Braintree::UnexpectedError)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
describe "#update_customer_session" do
|
|
62
|
+
let(:input) do
|
|
63
|
+
{
|
|
64
|
+
:merchant_account_id => "merchant-account-id", :session_id => "session-id"
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
let(:response) do
|
|
68
|
+
{
|
|
69
|
+
data: {
|
|
70
|
+
updateCustomerSession: {
|
|
71
|
+
sessionId: "session-id"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "executes the updateCustomerSession mutation" do
|
|
78
|
+
update_input = Braintree::UpdateCustomerSessionInput.new(input)
|
|
79
|
+
expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::UPDATE_CUSTOMER_SESSION,
|
|
80
|
+
{
|
|
81
|
+
"input" => update_input.to_graphql_variables
|
|
82
|
+
}).and_return(response)
|
|
83
|
+
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
|
|
84
|
+
result = customer_session_gateway.update_customer_session(update_input)
|
|
85
|
+
expect(result).to be_a(Braintree::SuccessfulResult)
|
|
86
|
+
expect(result.session_id).to eq("session-id")
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#get_customer_recommendations" do
|
|
91
|
+
let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id"}) }
|
|
92
|
+
let(:response) do
|
|
93
|
+
{
|
|
94
|
+
data: {
|
|
95
|
+
generateCustomerRecommendations: {
|
|
96
|
+
sessionId: "session_id",
|
|
97
|
+
isInPayPalNetwork: true,
|
|
98
|
+
paymentRecommendations:[
|
|
99
|
+
{paymentOption: "PAYPAL", recommendedPriority: 1},
|
|
100
|
+
{paymentOption: "VENMO", recommendedPriority: 2}
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "fetches customer recommendations" do
|
|
109
|
+
expected_variables = {"input" => {"sessionId" => "session_id"}}
|
|
110
|
+
expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::GET_CUSTOMER_RECOMMENDATIONS, expected_variables).and_return(response)
|
|
111
|
+
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
|
|
112
|
+
|
|
113
|
+
result = customer_session_gateway.get_customer_recommendations(customer_recommendations_input)
|
|
114
|
+
expect(result).to be_a(Braintree::SuccessfulResult)
|
|
115
|
+
expect(result.customer_recommendations.is_in_paypal_network).to eq(true)
|
|
116
|
+
expect(result.customer_recommendations.session_id).to eq("session_id")
|
|
117
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].payment_option).to eq("PAYPAL")
|
|
118
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].recommended_priority).to eq(1)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
@@ -105,7 +105,7 @@ describe Braintree::Customer do
|
|
|
105
105
|
:payment_method_nonce,
|
|
106
106
|
{:external_vault=>[:network_transaction_id]},
|
|
107
107
|
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
|
108
|
-
:fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
|
108
|
+
:account_information_inquiry, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
|
109
109
|
{:billing_address => [
|
|
110
110
|
:company,
|
|
111
111
|
:country_code_alpha2,
|
|
@@ -202,6 +202,7 @@ describe Braintree::Customer do
|
|
|
202
202
|
:payment_method_nonce,
|
|
203
203
|
{:external_vault=>[:network_transaction_id]},
|
|
204
204
|
{:options => match_array([
|
|
205
|
+
:account_information_inquiry,
|
|
205
206
|
:make_default,
|
|
206
207
|
:skip_advanced_fraud_checking,
|
|
207
208
|
:verification_merchant_account_id,
|
|
@@ -40,6 +40,7 @@ describe Braintree::Dispute do
|
|
|
40
40
|
:timestamp => Time.utc(2009, 3, 9, 10, 50, 39),
|
|
41
41
|
}
|
|
42
42
|
],
|
|
43
|
+
:remaining_file_evidence_storage => 341029,
|
|
43
44
|
:transaction => {
|
|
44
45
|
:amount => "31.00",
|
|
45
46
|
:id => "open_disputed_transaction",
|
|
@@ -436,6 +437,11 @@ describe Braintree::Dispute do
|
|
|
436
437
|
|
|
437
438
|
expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
|
438
439
|
end
|
|
440
|
+
|
|
441
|
+
it "checks that the remaining_file_evidence_storage field is set correctly" do
|
|
442
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
443
|
+
dispute.remaining_file_evidence_storage.should == 341029
|
|
444
|
+
end
|
|
439
445
|
end
|
|
440
446
|
|
|
441
447
|
describe "==" do
|
|
@@ -14,6 +14,34 @@ describe Braintree::ErrorResult do
|
|
|
14
14
|
)
|
|
15
15
|
end.to_not raise_error
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
it "handles parsed XML error response structure correctly" do
|
|
19
|
+
data = {
|
|
20
|
+
:message => "Validation failed",
|
|
21
|
+
:errors => {
|
|
22
|
+
:errors => [{:code => "81234", :message => "Field is required"}]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
expect do
|
|
27
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
28
|
+
expect(result.message).to eq("Validation failed")
|
|
29
|
+
expect(result.errors.inspect).to eq("#<Braintree::Errors :[(81234) Field is required]>")
|
|
30
|
+
end.to_not raise_error
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "handles empty error array in parsed XML response" do
|
|
34
|
+
data = {
|
|
35
|
+
:message => "Invalid request",
|
|
36
|
+
:errors => {:errors => []}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
expect do
|
|
40
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
41
|
+
expect(result.message).to eq("Invalid request")
|
|
42
|
+
expect(result.errors).to be_a(Braintree::Errors)
|
|
43
|
+
end.to_not raise_error
|
|
44
|
+
end
|
|
17
45
|
end
|
|
18
46
|
|
|
19
47
|
describe "inspect" do
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::GooglePayCard do
|
|
4
|
+
it "initializes prepaid reloadable correctly" do
|
|
5
|
+
card = Braintree::GooglePayCard._new(:gateway, {:prepaid_reloadable => "No"})
|
|
6
|
+
expect(card.prepaid_reloadable).to eq("No")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "initializes business correctly" do
|
|
10
|
+
card = Braintree::GooglePayCard._new(:gateway, {:business => "No"})
|
|
11
|
+
expect(card.business).to eq("No")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "initializes consumer correctly" do
|
|
15
|
+
card = Braintree::GooglePayCard._new(:gateway, {:consumer => "No"})
|
|
16
|
+
expect(card.consumer).to eq("No")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "initializes corporate correctly" do
|
|
20
|
+
card = Braintree::GooglePayCard._new(:gateway, {:corporate => "No"})
|
|
21
|
+
expect(card.corporate).to eq("No")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "initializes purchase correctly" do
|
|
25
|
+
card = Braintree::GooglePayCard._new(:gateway, {:purchase => "No"})
|
|
26
|
+
expect(card.purchase).to eq("No")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::CreateCustomerSessionInput do
|
|
5
|
+
let(:input_data) do
|
|
6
|
+
{
|
|
7
|
+
merchant_account_id: "merchant-account-id",
|
|
8
|
+
session_id: "session-id",
|
|
9
|
+
customer: {
|
|
10
|
+
email: "test@example.com" ,
|
|
11
|
+
},
|
|
12
|
+
domain: "example.com",
|
|
13
|
+
purchase_units: [
|
|
14
|
+
{
|
|
15
|
+
amount: {
|
|
16
|
+
value: "100.00",
|
|
17
|
+
currency_code: "USD"
|
|
18
|
+
},
|
|
19
|
+
payee: {
|
|
20
|
+
email_address: "merchant@example.com",
|
|
21
|
+
client_id: "client-123"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#initialize" do
|
|
29
|
+
it "initializes with attributes" do
|
|
30
|
+
input = Braintree::CreateCustomerSessionInput.new(input_data)
|
|
31
|
+
|
|
32
|
+
expect(input.attrs).to eq(input_data.keys)
|
|
33
|
+
expect(input.merchant_account_id).to eq("merchant-account-id")
|
|
34
|
+
expect(input.session_id).to eq("session-id")
|
|
35
|
+
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
|
36
|
+
expect(input.customer.email).to eq("test@example.com")
|
|
37
|
+
expect(input.domain).to eq("example.com")
|
|
38
|
+
expect(input.purchase_units).to be_a(Array)
|
|
39
|
+
expect(input.purchase_units.first).to be_a(Braintree::PayPalPurchaseUnitInput)
|
|
40
|
+
expect(input.purchase_units.first.amount.value).to eq("100.00")
|
|
41
|
+
expect(input.purchase_units.first.payee.email_address).to eq("merchant@example.com")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "handles nil customer" do
|
|
45
|
+
attributes = {merchant_account_id: "merchant-account-id"}
|
|
46
|
+
input = Braintree::CreateCustomerSessionInput.new(attributes)
|
|
47
|
+
expect(input.customer).to be_nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
describe "#inspect" do
|
|
53
|
+
it "returns a string representation of the object" do
|
|
54
|
+
input = Braintree::CreateCustomerSessionInput.new(input_data)
|
|
55
|
+
expected_string = "#<Braintree::CreateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\"> domain:\"example.com\" purchase_units:[#<Braintree::PayPalPurchaseUnitInput amount:#<Braintree::MonetaryAmountInput value:\"100.00\" currency_code:\"USD\"> payee:#<Braintree::PayPalPayeeInput email_address:\"merchant@example.com\" client_id:\"client-123\">>]>"
|
|
56
|
+
expect(input.inspect).to eq(expected_string)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "handles nil values" do
|
|
60
|
+
attributes = {
|
|
61
|
+
merchant_account_id: "merchant-account-id",
|
|
62
|
+
session_id: nil,
|
|
63
|
+
customer: nil
|
|
64
|
+
}
|
|
65
|
+
input = Braintree::CreateCustomerSessionInput.new(attributes)
|
|
66
|
+
expected_string = "#<Braintree::CreateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:nil customer:nil>"
|
|
67
|
+
|
|
68
|
+
expect(input.inspect).to eq(expected_string)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "#to_graphql_variables" do
|
|
74
|
+
it "converts the input to graphql variables" do
|
|
75
|
+
input = Braintree::CreateCustomerSessionInput.new(input_data)
|
|
76
|
+
expected_variables = {
|
|
77
|
+
"merchantAccountId" => "merchant-account-id",
|
|
78
|
+
"sessionId" => "session-id",
|
|
79
|
+
"domain" => "example.com",
|
|
80
|
+
"customer" => {"email" => "test@example.com"},
|
|
81
|
+
"purchaseUnits" => [
|
|
82
|
+
{
|
|
83
|
+
"amount" => {"value" => "100.00", "currencyCode" => "USD"},
|
|
84
|
+
"payee" => {"emailAddress" => "merchant@example.com", "clientId" => "client-123"}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "handles nil values" do
|
|
95
|
+
attributes = {merchant_account_id: "merchant-account-id"}
|
|
96
|
+
input = Braintree::CreateCustomerSessionInput.new(attributes)
|
|
97
|
+
expected_variables = {"merchantAccountId" => "merchant-account-id"}
|
|
98
|
+
|
|
99
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::CustomerRecommendationsInput do
|
|
5
|
+
let(:input_data) do
|
|
6
|
+
{
|
|
7
|
+
merchant_account_id: "merchant-account-id",
|
|
8
|
+
session_id: "session-id",
|
|
9
|
+
customer: {email: "test@example.com"},
|
|
10
|
+
purchase_units: [
|
|
11
|
+
{
|
|
12
|
+
amount: {
|
|
13
|
+
value: "100.00",
|
|
14
|
+
currency_code: "USD"
|
|
15
|
+
},
|
|
16
|
+
payee: {
|
|
17
|
+
email_address: "merchant@example.com",
|
|
18
|
+
client_id: "client-123"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
domain: "example.com"
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
describe "#initialize" do
|
|
26
|
+
it "initializes with attributes" do
|
|
27
|
+
input = Braintree::CustomerRecommendationsInput.new(input_data)
|
|
28
|
+
|
|
29
|
+
expect(input.attrs).to eq(input_data.keys)
|
|
30
|
+
expect(input.merchant_account_id).to eq("merchant-account-id")
|
|
31
|
+
expect(input.session_id).to eq("session-id")
|
|
32
|
+
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "handles nil customer" do
|
|
36
|
+
attributes = {
|
|
37
|
+
merchant_account_id: "merchant-account-id",
|
|
38
|
+
session_id: "session-id"
|
|
39
|
+
}
|
|
40
|
+
input = Braintree::CustomerRecommendationsInput.new(attributes)
|
|
41
|
+
|
|
42
|
+
expect(input.customer).to be_nil
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "#inspect" do
|
|
47
|
+
it "returns a string representation of the object" do
|
|
48
|
+
input = Braintree::CustomerRecommendationsInput.new(input_data)
|
|
49
|
+
expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\"> purchase_units:[#<Braintree::PayPalPurchaseUnitInput amount:#<Braintree::MonetaryAmountInput value:\"100.00\" currency_code:\"USD\"> payee:#<Braintree::PayPalPayeeInput email_address:\"merchant@example.com\" client_id:\"client-123\">>] domain:\"example.com\">"
|
|
50
|
+
expect(input.inspect).to eq(expected_string)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "handles nil values and returns a string representation" do
|
|
54
|
+
attributes = {
|
|
55
|
+
merchant_account_id: "merchant-account-id",
|
|
56
|
+
session_id: "session-id"
|
|
57
|
+
}
|
|
58
|
+
input = Braintree::CustomerRecommendationsInput.new(attributes)
|
|
59
|
+
expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\">"
|
|
60
|
+
|
|
61
|
+
expect(input.inspect).to eq(expected_string)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "#to_graphql_variables" do
|
|
67
|
+
it "converts the input to graphql variables" do
|
|
68
|
+
input = Braintree::CustomerRecommendationsInput.new(input_data)
|
|
69
|
+
expected_variables = {
|
|
70
|
+
"merchantAccountId" => "merchant-account-id",
|
|
71
|
+
"sessionId" => "session-id",
|
|
72
|
+
"customer" => {"email" => "test@example.com"},
|
|
73
|
+
"purchaseUnits" => [{"amount"=>{"currencyCode"=>"USD", "value"=>"100.00"}, "payee"=>{"clientId"=>"client-123", "emailAddress"=>"merchant@example.com"}}],
|
|
74
|
+
"domain" => "example.com"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::CustomerRecommendations do
|
|
4
|
+
let(:recommendation_data) do
|
|
5
|
+
[
|
|
6
|
+
{
|
|
7
|
+
paymentOption: "PAYPAL",
|
|
8
|
+
recommendedPriority: 1
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
paymentOption: "VENMO",
|
|
12
|
+
recommendedPriority: 2
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#initialize" do
|
|
18
|
+
it "creates payment_recommendations correctly" do
|
|
19
|
+
recs = Braintree::CustomerRecommendations.new(payment_recommendations: recommendation_data)
|
|
20
|
+
expect(recs.payment_recommendations.size).to eq(2)
|
|
21
|
+
expect(recs.payment_recommendations.first).to be_a(Braintree::PaymentRecommendations)
|
|
22
|
+
expect(recs.payment_recommendations.first.payment_option).to eq("PAYPAL")
|
|
23
|
+
expect(recs.payment_recommendations.last.payment_option).to eq("VENMO")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "creates payment_options from payment_recommendations" do
|
|
27
|
+
recs = Braintree::CustomerRecommendations.new(payment_recommendations: recommendation_data)
|
|
28
|
+
expect(recs.payment_options.size).to eq(2)
|
|
29
|
+
expect(recs.payment_options.first).to be_a(Braintree::PaymentOptions)
|
|
30
|
+
expect(recs.payment_options.first.payment_option).to eq("PAYPAL")
|
|
31
|
+
expect(recs.payment_options.last.payment_option).to eq("VENMO")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "is null safe if no recommendations are passed in" do
|
|
35
|
+
recs = Braintree::CustomerRecommendations.new
|
|
36
|
+
expect(recs.payment_recommendations).to eq([])
|
|
37
|
+
expect(recs.payment_options).to eq([])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::CustomerSessionInput do
|
|
5
|
+
let(:input_data) do
|
|
6
|
+
{
|
|
7
|
+
email: "test@example.com" ,
|
|
8
|
+
phone: {
|
|
9
|
+
country_phone_code: "1",
|
|
10
|
+
phone_number: "555-123-4567",
|
|
11
|
+
extension_number: "123",
|
|
12
|
+
},
|
|
13
|
+
user_agent: "Mozilla"
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#initialize" do
|
|
18
|
+
it "initializes with attributes" do
|
|
19
|
+
input = Braintree::CustomerSessionInput.new(input_data)
|
|
20
|
+
|
|
21
|
+
expect(input.attrs).to eq(input_data.keys)
|
|
22
|
+
expect(input.email).to eq("test@example.com")
|
|
23
|
+
expect(input.phone.country_phone_code).to eq("1")
|
|
24
|
+
expect(input.phone.phone_number).to eq("555-123-4567")
|
|
25
|
+
expect(input.phone.extension_number).to eq("123")
|
|
26
|
+
expect(input.user_agent).to eq("Mozilla")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "handles nil email" do
|
|
30
|
+
attributes = {}
|
|
31
|
+
input = Braintree::CustomerSessionInput.new(attributes)
|
|
32
|
+
expect(input.email).to be_nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
describe "#inspect" do
|
|
38
|
+
it "returns a string representation of the object" do
|
|
39
|
+
input = Braintree::CustomerSessionInput.new(input_data)
|
|
40
|
+
expected_string = "#<Braintree::CustomerSessionInput email:\"test@example.com\" phone:#<Braintree::PhoneInput country_phone_code:\"1\" phone_number:\"555-123-4567\" extension_number:\"123\"> user_agent:\"Mozilla\">"
|
|
41
|
+
expect(input.inspect).to eq(expected_string)
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "handles nil values" do
|
|
46
|
+
attributes = {}
|
|
47
|
+
input = Braintree::CustomerSessionInput.new(attributes)
|
|
48
|
+
expected_string = "#<Braintree::CustomerSessionInput >"
|
|
49
|
+
|
|
50
|
+
expect(input.inspect).to eq(expected_string)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "#to_graphql_variables" do
|
|
56
|
+
it "converts the input to graphql variables" do
|
|
57
|
+
input = Braintree::CustomerSessionInput.new(input_data)
|
|
58
|
+
expected_variables = {
|
|
59
|
+
"email" => "test@example.com",
|
|
60
|
+
"phone" => {
|
|
61
|
+
"countryPhoneCode" => "1",
|
|
62
|
+
"phoneNumber" => "555-123-4567",
|
|
63
|
+
"extensionNumber" => "123"
|
|
64
|
+
},
|
|
65
|
+
"userAgent" => "Mozilla"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "handles nil values" do
|
|
74
|
+
attributes = {}
|
|
75
|
+
input = Braintree::CustomerSessionInput.new(attributes)
|
|
76
|
+
expected_variables = {}
|
|
77
|
+
|
|
78
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|