braintree 4.27.0 → 4.28.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 +4 -0
- data/lib/braintree/bin_data.rb +7 -2
- data/lib/braintree/credit_card.rb +11 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +1 -0
- data/lib/braintree/customer_session_gateway.rb +11 -10
- data/lib/braintree/google_pay_card.rb +4 -0
- data/lib/braintree/graphql/enums/recommendations.rb +2 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
- data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -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 +2 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
- data/lib/braintree/graphql/types/payment_options.rb +2 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
- data/lib/braintree/meta_checkout_card.rb +8 -4
- data/lib/braintree/meta_checkout_token.rb +10 -6
- data/lib/braintree/payment_method_gateway.rb +3 -0
- data/lib/braintree/test/credit_card.rb +4 -0
- data/lib/braintree/transaction/apple_pay_details.rb +4 -0
- data/lib/braintree/transaction/credit_card_details.rb +8 -0
- data/lib/braintree/transaction/google_pay_details.rb +4 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
- data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
- data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +9 -4
- data/lib/braintree.rb +4 -0
- data/spec/integration/braintree/credit_card_spec.rb +101 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
- data/spec/integration/braintree/customer_session_spec.rb +59 -49
- data/spec/integration/braintree/customer_spec.rb +71 -4
- data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
- data/spec/integration/braintree/payment_method_spec.rb +47 -0
- data/spec/integration/braintree/transaction_spec.rb +61 -25
- data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
- data/spec/unit/braintree/credit_card_spec.rb +22 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
- data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction_spec.rb +8 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
- data/spec/unit/credit_card_details_spec.rb +20 -0
- metadata +7 -2
@@ -280,6 +280,58 @@ describe Braintree::Transaction do
|
|
280
280
|
expect(result.transaction.credit_card_details.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
281
281
|
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
282
282
|
end
|
283
|
+
|
284
|
+
it "sets the business field if the card is business" do
|
285
|
+
result = Braintree::Transaction.create(
|
286
|
+
:type => "sale",
|
287
|
+
:amount => 1_00,
|
288
|
+
:credit_card => {
|
289
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
290
|
+
:expiration_date => "05/2009"
|
291
|
+
},
|
292
|
+
)
|
293
|
+
expect(result.transaction.credit_card_details.business).to eq(Braintree::CreditCard::Business::Yes)
|
294
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "sets the consumer field if the card is consumer" do
|
298
|
+
result = Braintree::Transaction.create(
|
299
|
+
:type => "sale",
|
300
|
+
:amount => 1_00,
|
301
|
+
:credit_card => {
|
302
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
303
|
+
:expiration_date => "05/2009"
|
304
|
+
},
|
305
|
+
)
|
306
|
+
expect(result.transaction.credit_card_details.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
|
307
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
308
|
+
end
|
309
|
+
|
310
|
+
it "sets the corporate field if the card is corporate" do
|
311
|
+
result = Braintree::Transaction.create(
|
312
|
+
:type => "sale",
|
313
|
+
:amount => 1_00,
|
314
|
+
:credit_card => {
|
315
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
316
|
+
:expiration_date => "05/2009"
|
317
|
+
},
|
318
|
+
)
|
319
|
+
expect(result.transaction.credit_card_details.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
|
320
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "sets the purchase field if the card is purchase" do
|
324
|
+
result = Braintree::Transaction.create(
|
325
|
+
:type => "sale",
|
326
|
+
:amount => 1_00,
|
327
|
+
:credit_card => {
|
328
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
329
|
+
:expiration_date => "05/2009"
|
330
|
+
},
|
331
|
+
)
|
332
|
+
expect(result.transaction.credit_card_details.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
|
333
|
+
expect(result.transaction.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
334
|
+
end
|
283
335
|
end
|
284
336
|
|
285
337
|
describe "sca_exemption" do
|
@@ -2081,9 +2133,12 @@ describe Braintree::Transaction do
|
|
2081
2133
|
meta_checkout_card_details = result.transaction.meta_checkout_card_details
|
2082
2134
|
meta_checkout_card_details.should_not be_nil
|
2083
2135
|
meta_checkout_card_details.bin.should == "401288"
|
2136
|
+
meta_checkout_card_details.business.should == "Unknown"
|
2084
2137
|
meta_checkout_card_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2085
2138
|
meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
|
2139
|
+
meta_checkout_card_details.consumer.should == "Unknown"
|
2086
2140
|
meta_checkout_card_details.container_id.should == "container123"
|
2141
|
+
meta_checkout_card_details.corporate.should == "Unknown"
|
2087
2142
|
meta_checkout_card_details.customer_location.should == "US"
|
2088
2143
|
next_year = Date.today().next_year().year.to_s
|
2089
2144
|
meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
|
@@ -2095,6 +2150,7 @@ describe Braintree::Transaction do
|
|
2095
2150
|
meta_checkout_card_details.masked_number.should == "401288******1881"
|
2096
2151
|
meta_checkout_card_details.prepaid.should == "No"
|
2097
2152
|
meta_checkout_card_details.prepaid_reloadable.should == "Unknown"
|
2153
|
+
meta_checkout_card_details.purchase.should == "Unknown"
|
2098
2154
|
end
|
2099
2155
|
|
2100
2156
|
it "can create a transaction with a fake meta checkout token nonce" do
|
@@ -2110,9 +2166,12 @@ describe Braintree::Transaction do
|
|
2110
2166
|
|
2111
2167
|
meta_checkout_token_details.should_not be_nil
|
2112
2168
|
meta_checkout_token_details.bin.should == "401288"
|
2169
|
+
meta_checkout_token_details.business.should == "Unknown"
|
2113
2170
|
meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2114
2171
|
meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder"
|
2172
|
+
meta_checkout_token_details.consumer.should == "Unknown"
|
2115
2173
|
meta_checkout_token_details.container_id.should == "container123"
|
2174
|
+
meta_checkout_token_details.corporate.should == "Unknown"
|
2116
2175
|
meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
2117
2176
|
meta_checkout_token_details.customer_location.should == "US"
|
2118
2177
|
meta_checkout_token_details.ecommerce_indicator.should == "07"
|
@@ -2126,6 +2185,7 @@ describe Braintree::Transaction do
|
|
2126
2185
|
meta_checkout_token_details.masked_number.should == "401288******1881"
|
2127
2186
|
meta_checkout_token_details.prepaid.should == "No"
|
2128
2187
|
meta_checkout_token_details.prepaid_reloadable.should == "Unknown"
|
2188
|
+
meta_checkout_token_details.purchase.should == "Unknown"
|
2129
2189
|
end
|
2130
2190
|
|
2131
2191
|
it "can create a transaction with a fake apple pay nonce" do
|
@@ -2903,30 +2963,6 @@ describe Braintree::Transaction do
|
|
2903
2963
|
expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid)
|
2904
2964
|
end
|
2905
2965
|
|
2906
|
-
it "returns an error for transaction when the three_d_secure_pass_thru authentication_response is invalid" do
|
2907
|
-
result = Braintree::Transaction.create(
|
2908
|
-
:type => "sale",
|
2909
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2910
|
-
:merchant_account_id => SpecHelper:: AdyenMerchantAccountId,
|
2911
|
-
:credit_card => {
|
2912
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2913
|
-
:expiration_date => "12/12",
|
2914
|
-
},
|
2915
|
-
:three_d_secure_pass_thru => {
|
2916
|
-
:eci_flag => "05",
|
2917
|
-
:cavv => "some_cavv",
|
2918
|
-
:xid => "some_xid",
|
2919
|
-
:three_d_secure_version => "1.0.2",
|
2920
|
-
:authentication_response => "asdf",
|
2921
|
-
:directory_response => "Y",
|
2922
|
-
:cavv_algorithm => "2",
|
2923
|
-
:ds_transaction_id => "some_ds_id",
|
2924
|
-
},
|
2925
|
-
)
|
2926
|
-
expect(result.success?).to eq(false)
|
2927
|
-
expect(result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code).to eq(Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid)
|
2928
|
-
end
|
2929
|
-
|
2930
2966
|
it "returns an error for transaction when the three_d_secure_pass_thru directory_response is invalid" do
|
2931
2967
|
result = Braintree::Transaction.create(
|
2932
2968
|
:type => "sale",
|
@@ -7718,4 +7754,4 @@ describe Braintree::Transaction do
|
|
7718
7754
|
expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
7719
7755
|
end
|
7720
7756
|
end
|
7721
|
-
end
|
7757
|
+
end
|
@@ -19,9 +19,12 @@ describe Braintree::ApplePayCard do
|
|
19
19
|
street_address: "123 Sesame Street",
|
20
20
|
},
|
21
21
|
:bin => "411111",
|
22
|
+
:business => "No",
|
22
23
|
:card_type => "Apple Pay - MasterCard",
|
23
24
|
:cardholder_name => "John Miller",
|
24
25
|
:commercial => "No",
|
26
|
+
:consumer => "No",
|
27
|
+
:corporate => "No",
|
25
28
|
:country_of_issuance => "USA",
|
26
29
|
:created_at => Time.now,
|
27
30
|
:customer_id => "cid1",
|
@@ -41,6 +44,7 @@ describe Braintree::ApplePayCard do
|
|
41
44
|
:prepaid => "No",
|
42
45
|
:prepaid_reloadable => "No",
|
43
46
|
:product_id => "MAC",
|
47
|
+
:purchase => "No",
|
44
48
|
:source_card_last4 => "1234",
|
45
49
|
:source_description => "blah",
|
46
50
|
:subscriptions => [
|
@@ -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,
|
@@ -271,4 +271,24 @@ describe Braintree::CreditCard do
|
|
271
271
|
card = Braintree::CreditCard._new(:gateway, {:prepaid_reloadable => "No"})
|
272
272
|
expect(card.prepaid_reloadable).to eq("No")
|
273
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
|
274
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")
|
@@ -88,32 +88,33 @@ describe Braintree::CustomerSessionGateway do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#get_customer_recommendations" do
|
91
|
-
let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id"
|
91
|
+
let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id"}) }
|
92
92
|
let(:response) do
|
93
93
|
{
|
94
94
|
data: {
|
95
|
-
|
95
|
+
generateCustomerRecommendations: {
|
96
|
+
sessionId: "session_id",
|
96
97
|
isInPayPalNetwork: true,
|
97
|
-
|
98
|
-
|
99
|
-
{paymentOption: "
|
98
|
+
paymentRecommendations:[
|
99
|
+
{paymentOption: "PAYPAL", recommendedPriority: 1},
|
100
|
+
{paymentOption: "VENMO", recommendedPriority: 2}
|
100
101
|
]
|
101
|
-
|
102
|
+
|
102
103
|
}
|
103
104
|
}
|
104
105
|
}
|
105
106
|
end
|
106
107
|
|
107
108
|
it "fetches customer recommendations" do
|
108
|
-
expected_variables = {"input" => {"sessionId" => "session_id"
|
109
|
+
expected_variables = {"input" => {"sessionId" => "session_id"}}
|
109
110
|
expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::GET_CUSTOMER_RECOMMENDATIONS, expected_variables).and_return(response)
|
110
111
|
expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
|
111
112
|
|
112
113
|
result = customer_session_gateway.get_customer_recommendations(customer_recommendations_input)
|
113
114
|
expect(result).to be_a(Braintree::SuccessfulResult)
|
114
115
|
expect(result.customer_recommendations.is_in_paypal_network).to eq(true)
|
115
|
-
expect(result.customer_recommendations.recommendations.
|
116
|
-
expect(result.customer_recommendations.recommendations.
|
116
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].payment_option).to eq("PAYPAL")
|
117
|
+
expect(result.customer_recommendations.recommendations.payment_recommendations[0].recommended_priority).to eq(1)
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -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,
|
@@ -5,4 +5,24 @@ describe Braintree::GooglePayCard do
|
|
5
5
|
card = Braintree::GooglePayCard._new(:gateway, {:prepaid_reloadable => "No"})
|
6
6
|
expect(card.prepaid_reloadable).to eq("No")
|
7
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
|
8
28
|
end
|
@@ -9,7 +9,19 @@ describe Braintree::CreateCustomerSessionInput do
|
|
9
9
|
customer: {
|
10
10
|
email: "test@example.com" ,
|
11
11
|
},
|
12
|
-
domain: "example.com"
|
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
|
+
]
|
13
25
|
}
|
14
26
|
end
|
15
27
|
|
@@ -23,6 +35,10 @@ describe Braintree::CreateCustomerSessionInput do
|
|
23
35
|
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
24
36
|
expect(input.customer.email).to eq("test@example.com")
|
25
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")
|
26
42
|
end
|
27
43
|
|
28
44
|
it "handles nil customer" do
|
@@ -36,9 +52,8 @@ describe Braintree::CreateCustomerSessionInput do
|
|
36
52
|
describe "#inspect" do
|
37
53
|
it "returns a string representation of the object" do
|
38
54
|
input = Braintree::CreateCustomerSessionInput.new(input_data)
|
39
|
-
expected_string = "#<Braintree::CreateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\"> domain:\"example.com\">"
|
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\">>]>"
|
40
56
|
expect(input.inspect).to eq(expected_string)
|
41
|
-
|
42
57
|
end
|
43
58
|
|
44
59
|
it "handles nil values" do
|
@@ -62,7 +77,13 @@ describe Braintree::CreateCustomerSessionInput do
|
|
62
77
|
"merchantAccountId" => "merchant-account-id",
|
63
78
|
"sessionId" => "session-id",
|
64
79
|
"domain" => "example.com",
|
65
|
-
"customer" => {"email" => "test@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
|
+
]
|
66
87
|
}
|
67
88
|
|
68
89
|
expect(input.to_graphql_variables).to eq(expected_variables)
|
@@ -6,8 +6,20 @@ describe Braintree::CustomerRecommendationsInput do
|
|
6
6
|
{
|
7
7
|
merchant_account_id: "merchant-account-id",
|
8
8
|
session_id: "session-id",
|
9
|
-
|
10
|
-
|
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"
|
11
23
|
}
|
12
24
|
end
|
13
25
|
describe "#initialize" do
|
@@ -18,34 +30,12 @@ describe Braintree::CustomerRecommendationsInput do
|
|
18
30
|
expect(input.merchant_account_id).to eq("merchant-account-id")
|
19
31
|
expect(input.session_id).to eq("session-id")
|
20
32
|
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
21
|
-
expect(input.recommendations[0]).to eq("PAYMENT_RECOMMENDATIONS")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "disallows nil session id" do
|
25
|
-
attributes = {
|
26
|
-
merchant_account_id: "merchant-account-id",
|
27
|
-
recommendations: ["PAYMENT_RECOMMENDATIONS"],
|
28
|
-
}
|
29
|
-
expect do
|
30
|
-
Braintree::CustomerRecommendationsInput.new(attributes)
|
31
|
-
end.to raise_error(ArgumentError, "Expected hash to contain a :session_id")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "disallows nil recommendations" do
|
35
|
-
attributes = {
|
36
|
-
merchant_account_id: "merchant-account-id",
|
37
|
-
session_id: "session-id",
|
38
|
-
}
|
39
|
-
expect do
|
40
|
-
Braintree::CustomerRecommendationsInput.new(attributes)
|
41
|
-
end.to raise_error(ArgumentError, "Expected hash to contain a :recommendations")
|
42
33
|
end
|
43
34
|
|
44
35
|
it "handles nil customer" do
|
45
36
|
attributes = {
|
46
37
|
merchant_account_id: "merchant-account-id",
|
47
|
-
session_id: "session-id"
|
48
|
-
recommendations: ["PAYMENT_RECOMMENDATIONS"],
|
38
|
+
session_id: "session-id"
|
49
39
|
}
|
50
40
|
input = Braintree::CustomerRecommendationsInput.new(attributes)
|
51
41
|
|
@@ -53,23 +43,20 @@ describe Braintree::CustomerRecommendationsInput do
|
|
53
43
|
end
|
54
44
|
end
|
55
45
|
|
56
|
-
|
57
46
|
describe "#inspect" do
|
58
47
|
it "returns a string representation of the object" do
|
59
48
|
input = Braintree::CustomerRecommendationsInput.new(input_data)
|
60
|
-
expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\"
|
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\">"
|
61
50
|
expect(input.inspect).to eq(expected_string)
|
62
|
-
|
63
51
|
end
|
64
52
|
|
65
|
-
it "handles nil values" do
|
53
|
+
it "handles nil values and returns a string representation" do
|
66
54
|
attributes = {
|
67
55
|
merchant_account_id: "merchant-account-id",
|
68
|
-
session_id: "session-id"
|
69
|
-
recommendations: ["PAYMENT_RECOMMENDATIONS"],
|
56
|
+
session_id: "session-id"
|
70
57
|
}
|
71
58
|
input = Braintree::CustomerRecommendationsInput.new(attributes)
|
72
|
-
expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\"
|
59
|
+
expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\">"
|
73
60
|
|
74
61
|
expect(input.inspect).to eq(expected_string)
|
75
62
|
end
|
@@ -83,28 +70,11 @@ describe Braintree::CustomerRecommendationsInput do
|
|
83
70
|
"merchantAccountId" => "merchant-account-id",
|
84
71
|
"sessionId" => "session-id",
|
85
72
|
"customer" => {"email" => "test@example.com"},
|
86
|
-
"
|
87
|
-
|
88
|
-
|
89
|
-
expect(input.to_graphql_variables).to eq(expected_variables)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "handles nil values" do
|
93
|
-
attributes = {
|
94
|
-
merchant_account_id: "merchant-account-id",
|
95
|
-
session_id: "session-id",
|
96
|
-
recommendations: ["PAYMENT_RECOMMENDATIONS"],
|
97
|
-
}
|
98
|
-
input = Braintree::CustomerRecommendationsInput.new(attributes)
|
99
|
-
|
100
|
-
expected_variables = {
|
101
|
-
"merchantAccountId" => "merchant-account-id",
|
102
|
-
"sessionId" => "session-id",
|
103
|
-
"recommendations" => ["PAYMENT_RECOMMENDATIONS"],
|
73
|
+
"purchaseUnits" => [{"amount"=>{"currencyCode"=>"USD", "value"=>"100.00"}, "payee"=>{"clientId"=>"client-123", "emailAddress"=>"merchant@example.com"}}],
|
74
|
+
"domain" => "example.com"
|
104
75
|
}
|
105
76
|
|
106
77
|
expect(input.to_graphql_variables).to eq(expected_variables)
|
107
78
|
end
|
108
79
|
end
|
109
|
-
|
110
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
|
@@ -3,11 +3,25 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
3
3
|
|
4
4
|
describe Braintree::UpdateCustomerSessionInput do
|
5
5
|
let(:input_data) do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
{
|
7
|
+
merchant_account_id: "merchant-account-id",
|
8
|
+
session_id: "session-id",
|
9
|
+
customer: {
|
10
|
+
email: "test@example.com"
|
11
|
+
},
|
12
|
+
purchase_units: [
|
13
|
+
{
|
14
|
+
amount: {
|
15
|
+
value: "100.00",
|
16
|
+
currency_code: "USD"
|
17
|
+
},
|
18
|
+
payee: {
|
19
|
+
email_address: "merchant@example.com",
|
20
|
+
client_id: "client-123"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
11
25
|
end
|
12
26
|
describe "#initialize" do
|
13
27
|
it "initializes with attributes" do
|
@@ -44,9 +58,8 @@ describe Braintree::UpdateCustomerSessionInput do
|
|
44
58
|
describe "#inspect" do
|
45
59
|
it "returns a string representation of the object" do
|
46
60
|
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
47
|
-
expected_string = "#<Braintree::UpdateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\">>"
|
61
|
+
expected_string = "#<Braintree::UpdateCustomerSessionInput 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\">>]>"
|
48
62
|
expect(input.inspect).to eq(expected_string)
|
49
|
-
|
50
63
|
end
|
51
64
|
|
52
65
|
it "handles nil values" do
|
@@ -69,6 +82,7 @@ describe Braintree::UpdateCustomerSessionInput do
|
|
69
82
|
"merchantAccountId" => "merchant-account-id",
|
70
83
|
"sessionId" => "session-id",
|
71
84
|
"customer" => {"email" => "test@example.com"},
|
85
|
+
"purchaseUnits" => [{"amount"=>{"currencyCode"=>"USD", "value"=>"100.00"}, "payee"=>{"clientId"=>"client-123", "emailAddress"=>"merchant@example.com"}}],
|
72
86
|
}
|
73
87
|
|
74
88
|
expect(input.to_graphql_variables).to eq(expected_variables)
|
@@ -4,10 +4,13 @@ describe Braintree::MetaCheckoutCard do
|
|
4
4
|
let(:attributes) do {
|
5
5
|
|
6
6
|
:bin => "abc1234",
|
7
|
+
:business => "NO",
|
7
8
|
:card_type => "Visa",
|
8
9
|
:cardholder_name => "Meta Checkout Card CardHolder",
|
9
10
|
:commercial => "NO",
|
11
|
+
:consumer => "NO",
|
10
12
|
:container_id => "a-container-id",
|
13
|
+
:corporate => "NO",
|
11
14
|
:country_of_issuance => "US",
|
12
15
|
:created_at => "2023-05-05T21:28:37Z",
|
13
16
|
:debit => "NO",
|
@@ -19,6 +22,7 @@ describe Braintree::MetaCheckoutCard do
|
|
19
22
|
:payroll => "NO",
|
20
23
|
:prepaid => "NO",
|
21
24
|
:prepaid_reloadable => "NO",
|
25
|
+
:purchase => "NO",
|
22
26
|
:token => "token1",
|
23
27
|
:unique_number_identifier => "abc1234",
|
24
28
|
:updated_at => "2023-05-05T21:28:37Z"
|
@@ -30,10 +34,13 @@ describe Braintree::MetaCheckoutCard do
|
|
30
34
|
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
31
35
|
|
32
36
|
card.bin.should == "abc1234"
|
37
|
+
card.business.should == "NO"
|
33
38
|
card.card_type.should == "Visa"
|
34
39
|
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
35
40
|
card.commercial == "NO"
|
41
|
+
card.consumer == "NO"
|
36
42
|
card.container_id.should == "a-container-id"
|
43
|
+
card.corporate == "NO"
|
37
44
|
card.country_of_issuance == "US"
|
38
45
|
card.created_at == "2023-05-05T21:28:37Z"
|
39
46
|
card.debit == "NO"
|
@@ -44,6 +51,7 @@ describe Braintree::MetaCheckoutCard do
|
|
44
51
|
card.payroll == "NO"
|
45
52
|
card.prepaid == "NO"
|
46
53
|
card.prepaid_reloadable == "NO"
|
54
|
+
card.purchase == "NO"
|
47
55
|
card.token == "token1"
|
48
56
|
card.unique_number_identifier == "abc1234"
|
49
57
|
card.updated_at == "2023-05-05T21:28:37Z"
|
@@ -3,10 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
3
3
|
describe Braintree::MetaCheckoutToken do
|
4
4
|
let(:attributes) do {
|
5
5
|
:bin => "abc1234",
|
6
|
+
:business => "NO",
|
6
7
|
:container_id => "a-container-id",
|
7
8
|
:card_type => "Visa",
|
8
9
|
:cardholder_name => "Meta Checkout Card CardHolder",
|
9
10
|
:commercial => "NO",
|
11
|
+
:consumer => "NO",
|
12
|
+
:corporate => "NO",
|
10
13
|
:country_of_issuance => "US",
|
11
14
|
:created_at => "2023-05-05T21:28:37Z",
|
12
15
|
:debit => "NO",
|
@@ -18,6 +21,7 @@ describe Braintree::MetaCheckoutToken do
|
|
18
21
|
:payroll => "NO",
|
19
22
|
:prepaid => "NO",
|
20
23
|
:prepaid_reloadable => "NO",
|
24
|
+
:purchase => "NO",
|
21
25
|
:token => "token1",
|
22
26
|
:unique_number_identifier => "abc1234",
|
23
27
|
:updated_at => "2023-05-05T21:28:37Z",
|
@@ -15,8 +15,12 @@ describe Braintree::PaymentMethodNonce do
|
|
15
15
|
:liability_shifted => false
|
16
16
|
},
|
17
17
|
:bin_data => {
|
18
|
+
:business => "No",
|
19
|
+
:consumer => "No",
|
20
|
+
:corporate => "No",
|
18
21
|
:country_of_issuance => "USA",
|
19
|
-
:prepaid_reloadable => "Yes"
|
22
|
+
:prepaid_reloadable => "Yes",
|
23
|
+
:purchase => "No",
|
20
24
|
},
|
21
25
|
)
|
22
26
|
}
|
@@ -29,9 +33,12 @@ describe Braintree::PaymentMethodNonce do
|
|
29
33
|
expect(payment_method_nonce.details.bin).to eq("some-bin")
|
30
34
|
expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
|
31
35
|
expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
|
36
|
+
expect(payment_method_nonce.bin_data.business).to eq("No")
|
37
|
+
expect(payment_method_nonce.bin_data.consumer).to eq("No")
|
38
|
+
expect(payment_method_nonce.bin_data.corporate).to eq("No")
|
32
39
|
expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
|
33
40
|
expect(payment_method_nonce.bin_data.prepaid_reloadable).to eq("Yes")
|
34
|
-
|
41
|
+
expect(payment_method_nonce.bin_data.purchase).to eq("No")
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|