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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::PhoneInput do
|
|
5
|
+
let(:phone_input_data) do
|
|
6
|
+
{
|
|
7
|
+
country_phone_code: "1",
|
|
8
|
+
phone_number: "555-123-4567",
|
|
9
|
+
extension_number: "123"
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let(:partial_phone_input_data) do
|
|
14
|
+
{
|
|
15
|
+
country_phone_code: "1",
|
|
16
|
+
phone_number: "555-123-4567"
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
describe "#initialize" do
|
|
22
|
+
it "initialize and sets the input keys to attrs variable" do
|
|
23
|
+
phone_input = described_class.new(phone_input_data)
|
|
24
|
+
|
|
25
|
+
expect(phone_input.attrs).to include(:country_phone_code)
|
|
26
|
+
expect(phone_input.attrs).to include(:phone_number)
|
|
27
|
+
expect(phone_input.attrs).to include(:extension_number)
|
|
28
|
+
expect(phone_input.attrs.length).to eq(3)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "inspect" do
|
|
33
|
+
it "includes all phone input attributes" do
|
|
34
|
+
phone_input = described_class.new(phone_input_data)
|
|
35
|
+
output = phone_input.inspect
|
|
36
|
+
|
|
37
|
+
expect(output).to include("country_phone_code:\"1\"")
|
|
38
|
+
expect(output).to include("phone_number:\"555-123-4567\"")
|
|
39
|
+
expect(output).to include("extension_number:\"123\"")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "includes only specified phone input attributes" do
|
|
43
|
+
phone_input = described_class.new(partial_phone_input_data)
|
|
44
|
+
output = phone_input.inspect
|
|
45
|
+
|
|
46
|
+
expect(output).to include("country_phone_code:\"1\"")
|
|
47
|
+
expect(output).to include("phone_number:\"555-123-4567\"")
|
|
48
|
+
expect(output).not_to include("extension_number")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::UpdateCustomerSessionInput 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
|
+
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
|
+
}
|
|
25
|
+
end
|
|
26
|
+
describe "#initialize" do
|
|
27
|
+
it "initializes with attributes" do
|
|
28
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
29
|
+
|
|
30
|
+
expect(input.attrs).to eq(input_data.keys)
|
|
31
|
+
expect(input.merchant_account_id).to eq("merchant-account-id")
|
|
32
|
+
expect(input.session_id).to eq("session-id")
|
|
33
|
+
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
|
34
|
+
expect(input.customer.email).to eq("test@example.com")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "disallows nil session id" do
|
|
38
|
+
attributes = {
|
|
39
|
+
merchant_account_id: "merchant-account-id",
|
|
40
|
+
}
|
|
41
|
+
expect do
|
|
42
|
+
Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
43
|
+
end.to raise_error(ArgumentError, "Expected hash to contain a :session_id")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "handles nil customer" do
|
|
47
|
+
attributes = {
|
|
48
|
+
merchant_account_id: "merchant-account-id",
|
|
49
|
+
session_id: "session-id",
|
|
50
|
+
}
|
|
51
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
52
|
+
|
|
53
|
+
expect(input.customer).to be_nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
describe "#inspect" do
|
|
59
|
+
it "returns a string representation of the object" do
|
|
60
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
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\">>]>"
|
|
62
|
+
expect(input.inspect).to eq(expected_string)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "handles nil values" do
|
|
66
|
+
attributes = {
|
|
67
|
+
merchant_account_id: "merchant-account-id",
|
|
68
|
+
session_id: "session-id",
|
|
69
|
+
}
|
|
70
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
71
|
+
expected_string = "#<Braintree::UpdateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\">"
|
|
72
|
+
|
|
73
|
+
expect(input.inspect).to eq(expected_string)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "#to_graphql_variables" do
|
|
79
|
+
it "converts the input to graphql variables" do
|
|
80
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
81
|
+
expected_variables = {
|
|
82
|
+
"merchantAccountId" => "merchant-account-id",
|
|
83
|
+
"sessionId" => "session-id",
|
|
84
|
+
"customer" => {"email" => "test@example.com"},
|
|
85
|
+
"purchaseUnits" => [{"amount"=>{"currencyCode"=>"USD", "value"=>"100.00"}, "payee"=>{"clientId"=>"client-123", "emailAddress"=>"merchant@example.com"}}],
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "handles nil values" do
|
|
92
|
+
attributes = {
|
|
93
|
+
merchant_account_id: "merchant-account-id",
|
|
94
|
+
session_id: "session-id",
|
|
95
|
+
}
|
|
96
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
97
|
+
|
|
98
|
+
expected_variables = {
|
|
99
|
+
"merchantAccountId" => "merchant-account-id",
|
|
100
|
+
"sessionId" => "session-id",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::GraphQLClient do
|
|
4
|
+
|
|
5
|
+
describe ".get_validation_errors" do
|
|
6
|
+
it "returns nil if no errors" do
|
|
7
|
+
expect(Braintree::GraphQLClient.get_validation_errors({})).to be_nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "returns nil if errors is not an array" do
|
|
11
|
+
expect(Braintree::GraphQLClient.get_validation_errors({:errors => "string"})).to be_nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "returns validation errors" do
|
|
15
|
+
response = {
|
|
16
|
+
:errors => [
|
|
17
|
+
{:message => "Invalid input", :extensions => {:legacyCode => "81803"}},
|
|
18
|
+
{:message => "Another error", :extensions => {:legacyCode => "91903"}}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
expected_errors = {
|
|
22
|
+
:errors => [
|
|
23
|
+
{:attribute => "", :code => "81803", :message => "Invalid input"},
|
|
24
|
+
{:attribute => "", :code => "91903", :message => "Another error"}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
expect(Braintree::GraphQLClient.get_validation_errors(response)).to eq(expected_errors)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
it "handles missing legacyCode" do
|
|
32
|
+
response = {:errors => [{:message => "Invalid input"}]}
|
|
33
|
+
expected_errors = {:errors => [{:attribute => "", :code => nil, :message => "Invalid input"}]}
|
|
34
|
+
expect(Braintree::GraphQLClient.get_validation_errors(response)).to eq(expected_errors)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -1,60 +1,70 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
2
|
|
|
3
3
|
describe Braintree::MetaCheckoutCard do
|
|
4
|
-
|
|
4
|
+
let(:attributes) do {
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
:bin => "abc1234",
|
|
7
|
+
:business => "NO",
|
|
8
|
+
:card_type => "Visa",
|
|
9
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
|
10
|
+
:commercial => "NO",
|
|
11
|
+
:consumer => "NO",
|
|
12
|
+
:container_id => "a-container-id",
|
|
13
|
+
:corporate => "NO",
|
|
14
|
+
:country_of_issuance => "US",
|
|
15
|
+
:created_at => "2023-05-05T21:28:37Z",
|
|
16
|
+
:debit => "NO",
|
|
17
|
+
:durbin_regulated => "NO",
|
|
18
|
+
:expiration_month => "05",
|
|
19
|
+
:expiration_year => "2024",
|
|
20
|
+
:healthcare => "NO",
|
|
21
|
+
:last_4 => "1234",
|
|
22
|
+
:payroll => "NO",
|
|
23
|
+
:prepaid => "NO",
|
|
24
|
+
:prepaid_reloadable => "NO",
|
|
25
|
+
:purchase => "NO",
|
|
26
|
+
:token => "token1",
|
|
27
|
+
:unique_number_identifier => "abc1234",
|
|
28
|
+
:updated_at => "2023-05-05T21:28:37Z"
|
|
29
|
+
}
|
|
30
|
+
end
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
describe "unit tests" do
|
|
33
|
+
it "initializes with the correct attributes" do
|
|
34
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
card.bin.should == "abc1234"
|
|
37
|
+
card.business.should == "NO"
|
|
38
|
+
card.card_type.should == "Visa"
|
|
39
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
|
40
|
+
card.commercial == "NO"
|
|
41
|
+
card.consumer == "NO"
|
|
42
|
+
card.container_id.should == "a-container-id"
|
|
43
|
+
card.corporate == "NO"
|
|
44
|
+
card.country_of_issuance == "US"
|
|
45
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
|
46
|
+
card.debit == "NO"
|
|
47
|
+
card.expiration_month.should == "05"
|
|
48
|
+
card.expiration_year.should == "2024"
|
|
49
|
+
card.healthcare == "NO"
|
|
50
|
+
card.last_4.should == "1234"
|
|
51
|
+
card.payroll == "NO"
|
|
52
|
+
card.prepaid == "NO"
|
|
53
|
+
card.prepaid_reloadable == "NO"
|
|
54
|
+
card.purchase == "NO"
|
|
55
|
+
card.token == "token1"
|
|
56
|
+
card.unique_number_identifier == "abc1234"
|
|
57
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
|
58
|
+
end
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
it "sets expiration date correctly" do
|
|
61
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
62
|
+
card.expiration_date.should == "05/2024"
|
|
63
|
+
end
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
65
|
+
it "masks the card number correctly" do
|
|
66
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
67
|
+
card.masked_number.should == "abc1234******1234"
|
|
59
68
|
end
|
|
60
|
-
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -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",
|
|
@@ -17,6 +20,8 @@ describe Braintree::MetaCheckoutToken do
|
|
|
17
20
|
:last_4 => "1234",
|
|
18
21
|
:payroll => "NO",
|
|
19
22
|
:prepaid => "NO",
|
|
23
|
+
:prepaid_reloadable => "NO",
|
|
24
|
+
:purchase => "NO",
|
|
20
25
|
:token => "token1",
|
|
21
26
|
:unique_number_identifier => "abc1234",
|
|
22
27
|
:updated_at => "2023-05-05T21:28:37Z",
|
|
@@ -40,6 +45,7 @@ describe Braintree::MetaCheckoutToken do
|
|
|
40
45
|
card.debit == "NO"
|
|
41
46
|
card.payroll == "NO"
|
|
42
47
|
card.prepaid == "NO"
|
|
48
|
+
card.prepaid_reloadable == "NO"
|
|
43
49
|
card.healthcare == "NO"
|
|
44
50
|
card.token == "token1"
|
|
45
51
|
card.unique_number_identifier == "abc1234"
|
|
@@ -60,4 +66,4 @@ describe Braintree::MetaCheckoutToken do
|
|
|
60
66
|
card.masked_number.should == "abc1234******1234"
|
|
61
67
|
end
|
|
62
68
|
end
|
|
63
|
-
end
|
|
69
|
+
end
|
|
@@ -15,7 +15,12 @@ describe Braintree::PaymentMethodNonce do
|
|
|
15
15
|
:liability_shifted => false
|
|
16
16
|
},
|
|
17
17
|
:bin_data => {
|
|
18
|
-
:
|
|
18
|
+
:business => "No",
|
|
19
|
+
:consumer => "No",
|
|
20
|
+
:corporate => "No",
|
|
21
|
+
:country_of_issuance => "USA",
|
|
22
|
+
:prepaid_reloadable => "Yes",
|
|
23
|
+
:purchase => "No",
|
|
19
24
|
},
|
|
20
25
|
)
|
|
21
26
|
}
|
|
@@ -28,7 +33,12 @@ describe Braintree::PaymentMethodNonce do
|
|
|
28
33
|
expect(payment_method_nonce.details.bin).to eq("some-bin")
|
|
29
34
|
expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
|
|
30
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")
|
|
31
39
|
expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
|
|
40
|
+
expect(payment_method_nonce.bin_data.prepaid_reloadable).to eq("Yes")
|
|
41
|
+
expect(payment_method_nonce.bin_data.purchase).to eq("No")
|
|
32
42
|
end
|
|
33
43
|
end
|
|
34
44
|
|
|
@@ -25,6 +25,18 @@ describe Braintree::PaymentMethod do
|
|
|
25
25
|
expect(result.payment_method.token).to eq(1234)
|
|
26
26
|
expect(result.payment_method).to be_instance_of(Braintree::UnknownPaymentMethod)
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
it "handles an payment method type for account information inquiry" do
|
|
30
|
+
unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
|
|
31
|
+
http_instance = double(:put => unknown_response)
|
|
32
|
+
allow(Braintree::Http).to receive(:new).and_return(http_instance)
|
|
33
|
+
result = Braintree::PaymentMethod.update(:unknown,
|
|
34
|
+
{:options => {:verify_card => true, :accountInformationInquiry => "send_data"}})
|
|
35
|
+
|
|
36
|
+
expect(result).to be_success
|
|
37
|
+
expect(result.payment_method.token).to eq(1234)
|
|
38
|
+
expect(result.payment_method).to be_instance_of(Braintree::UnknownPaymentMethod)
|
|
39
|
+
end
|
|
28
40
|
end
|
|
29
41
|
|
|
30
42
|
describe "delete" do
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PayPalPaymentResource do
|
|
4
|
+
|
|
5
|
+
describe "#update" do
|
|
6
|
+
it "successfully updates a paypal payment request" do
|
|
7
|
+
paypal_payment_resource_request = {
|
|
8
|
+
:amount => 55.00,
|
|
9
|
+
:amount_breakdown => {
|
|
10
|
+
:discount => 15_00,
|
|
11
|
+
:handling => 0,
|
|
12
|
+
:insurance => 5_00,
|
|
13
|
+
:item_total => 45_00,
|
|
14
|
+
:shipping => 10_00,
|
|
15
|
+
:shipping_discount => 0,
|
|
16
|
+
:tax_total => 10_00
|
|
17
|
+
},
|
|
18
|
+
:currency_iso_code => "USD",
|
|
19
|
+
:description => "This is a test",
|
|
20
|
+
:custom_field => "0437",
|
|
21
|
+
:line_items => [{
|
|
22
|
+
:description => "Shoes",
|
|
23
|
+
:image_url => "https://example.com/products/23434/pic.png",
|
|
24
|
+
:kind => "debit",
|
|
25
|
+
:name => "Name #1",
|
|
26
|
+
:product_code => "23434",
|
|
27
|
+
:quantity => 1_00,
|
|
28
|
+
:total_amount => 45_00,
|
|
29
|
+
:unit_amount => 45_00,
|
|
30
|
+
:unit_tax_amount => 10_00,
|
|
31
|
+
:url => "https://example.com/products/23434",
|
|
32
|
+
}],
|
|
33
|
+
:order_id => "order-123456789",
|
|
34
|
+
:payee_email => "bt_buyer_us@paypal.com",
|
|
35
|
+
:payment_method_nonce => "1234",
|
|
36
|
+
:shipping => {
|
|
37
|
+
:country_name => "United States",
|
|
38
|
+
:country_code_alpha2 => "US",
|
|
39
|
+
:country_code_alpha3 => "USA",
|
|
40
|
+
:country_code_numeric => "484",
|
|
41
|
+
:extended_address => "Apt. #1",
|
|
42
|
+
:first_name => "John",
|
|
43
|
+
:international_phone => {
|
|
44
|
+
:country_code => "1",
|
|
45
|
+
:national_number => "4081111111",
|
|
46
|
+
},
|
|
47
|
+
:last_name => "Doe",
|
|
48
|
+
:locality => "Chicago",
|
|
49
|
+
:postal_code => "60618",
|
|
50
|
+
:region => "IL",
|
|
51
|
+
:street_address => "123 Division Street",
|
|
52
|
+
},
|
|
53
|
+
:shipping_options => [{
|
|
54
|
+
:amount => "10.00",
|
|
55
|
+
:id => "option1",
|
|
56
|
+
:label => "fast",
|
|
57
|
+
:selected => true,
|
|
58
|
+
:type => "SHIPPING"
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
unknown_response = {:payment_method_nonce => {}}
|
|
63
|
+
http_instance = double(:put => unknown_response)
|
|
64
|
+
allow(Braintree::Http).to receive(:new).and_return(http_instance)
|
|
65
|
+
result = Braintree::PayPalPaymentResource.update(paypal_payment_resource_request)
|
|
66
|
+
expect(result).to be_success
|
|
67
|
+
end
|
|
68
|
+
it "should match the update signature" do
|
|
69
|
+
expect(Braintree::PayPalPaymentResourceGateway._update_signature).to match([
|
|
70
|
+
:amount,
|
|
71
|
+
{:amount_breakdown => [
|
|
72
|
+
:discount,
|
|
73
|
+
:handling,
|
|
74
|
+
:insurance,
|
|
75
|
+
:item_total,
|
|
76
|
+
:shipping,
|
|
77
|
+
:shipping_discount,
|
|
78
|
+
:tax_total
|
|
79
|
+
]},
|
|
80
|
+
:currency_iso_code,
|
|
81
|
+
:custom_field,
|
|
82
|
+
:description,
|
|
83
|
+
{:line_items => [
|
|
84
|
+
:description,
|
|
85
|
+
:image_url,
|
|
86
|
+
:kind,
|
|
87
|
+
:name,
|
|
88
|
+
:product_code,
|
|
89
|
+
:quantity,
|
|
90
|
+
:total_amount,
|
|
91
|
+
:unit_amount,
|
|
92
|
+
:unit_tax_amount,
|
|
93
|
+
:url,
|
|
94
|
+
]},
|
|
95
|
+
:order_id,
|
|
96
|
+
:payee_email,
|
|
97
|
+
:payment_method_nonce,
|
|
98
|
+
{:shipping => [
|
|
99
|
+
:country_name,
|
|
100
|
+
:country_code_alpha2,
|
|
101
|
+
:country_code_alpha3,
|
|
102
|
+
:country_code_numeric,
|
|
103
|
+
:extended_address,
|
|
104
|
+
:first_name,
|
|
105
|
+
{:international_phone => [
|
|
106
|
+
:country_code,
|
|
107
|
+
:national_number]},
|
|
108
|
+
:last_name,
|
|
109
|
+
:locality,
|
|
110
|
+
:postal_code,
|
|
111
|
+
:region,
|
|
112
|
+
:street_address,
|
|
113
|
+
]},
|
|
114
|
+
{:shipping_options => [
|
|
115
|
+
:amount,
|
|
116
|
+
:id,
|
|
117
|
+
:label,
|
|
118
|
+
:selected,
|
|
119
|
+
:type
|
|
120
|
+
]},
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::ApplePayDetails do
|
|
4
|
+
it "initializes prepaid reloadable correctly" do
|
|
5
|
+
card = Braintree::ApplePayDetails._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::ApplePayDetails._new(:gateway, {:business => "No"})
|
|
11
|
+
expect(card.business).to eq("No")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "initializes consumer correctly" do
|
|
15
|
+
card = Braintree::ApplePayDetails._new(:gateway, {:consumer => "No"})
|
|
16
|
+
expect(card.consumer).to eq("No")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "initializes corporate correctly" do
|
|
20
|
+
card = Braintree::ApplePayDetails._new(:gateway, {:corporate => "No"})
|
|
21
|
+
expect(card.corporate).to eq("No")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "initializes purchase correctly" do
|
|
25
|
+
card = Braintree::ApplePayDetails._new(:gateway, {:purchase => "No"})
|
|
26
|
+
expect(card.purchase).to eq("No")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "payment_account_reference" do
|
|
30
|
+
it "returns the payment account reference when present" do
|
|
31
|
+
details = Braintree::Transaction::ApplePayDetails.new(
|
|
32
|
+
:payment_account_reference => "V0010013019339005665779448477",
|
|
33
|
+
)
|
|
34
|
+
expect(details.payment_account_reference).to eq("V0010013019339005665779448477")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -15,6 +15,7 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
|
15
15
|
it "inspects" do
|
|
16
16
|
details = Braintree::Transaction::CreditCardDetails.new(
|
|
17
17
|
:bin => "123456",
|
|
18
|
+
:business => "No",
|
|
18
19
|
:card_type => "Visa",
|
|
19
20
|
:cardholder_name => "The Cardholder",
|
|
20
21
|
:expiration_month => "05",
|
|
@@ -24,17 +25,21 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
|
24
25
|
:customer_location => "US",
|
|
25
26
|
:healthcare => "No",
|
|
26
27
|
:prepaid => "Yes",
|
|
28
|
+
:prepaid_reloadable => "Yes",
|
|
27
29
|
:durbin_regulated => "No",
|
|
28
30
|
:debit => "Yes",
|
|
29
31
|
:commercial => "Unknown",
|
|
32
|
+
:consumer => "Unknown",
|
|
33
|
+
:corporate => "Unknown",
|
|
30
34
|
:payroll => "Unknown",
|
|
35
|
+
:purchase => "Unknown",
|
|
31
36
|
:product_id => "Unknown",
|
|
32
37
|
:country_of_issuance => "Lilliput",
|
|
33
38
|
:issuing_bank => "Gulliver Bank",
|
|
34
39
|
:image_url => "example.com/visa.png",
|
|
35
40
|
:unique_number_identifier => "abc123",
|
|
36
41
|
)
|
|
37
|
-
expect(details.inspect).to eq(%(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa",
|
|
42
|
+
expect(details.inspect).to eq(%(#<token: "token", bin: "123456", business: "No", last_4: "6789", card_type: "Visa", commercial: "Unknown", consumer: "Unknown", corporate: "Unknown", country_of_issuance: "Lilliput", customer_location: "US", debit: "Yes", durbin_regulated: "No", expiration_date: "05/2012", healthcare: "No", image_url: "example.com/visa.png", issuing_bank: "Gulliver Bank", payroll: "Unknown", prepaid: "Yes", prepaid_reloadable: "Yes", product_id: "Unknown", purchase: "Unknown", cardholder_name: "The Cardholder", unique_number_identifier: "abc123", payment_account_reference: nil>))
|
|
38
43
|
end
|
|
39
44
|
end
|
|
40
45
|
|
|
@@ -62,4 +67,13 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
|
62
67
|
expect(details.is_network_tokenized?).to eq(false)
|
|
63
68
|
end
|
|
64
69
|
end
|
|
70
|
+
|
|
71
|
+
describe "payment_account_reference" do
|
|
72
|
+
it "returns the payment account reference when present" do
|
|
73
|
+
details = Braintree::Transaction::CreditCardDetails.new(
|
|
74
|
+
:payment_account_reference => "V0010013019339005665779448477",
|
|
75
|
+
)
|
|
76
|
+
expect(details.payment_account_reference).to eq("V0010013019339005665779448477")
|
|
77
|
+
end
|
|
78
|
+
end
|
|
65
79
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::GooglePayDetails do
|
|
4
|
+
it "initializes prepaid reloadable correctly" do
|
|
5
|
+
card = Braintree::GooglePayDetails._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::GooglePayDetails._new(:gateway, {:business => "No"})
|
|
11
|
+
expect(card.business).to eq("No")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "initializes consumer correctly" do
|
|
15
|
+
card = Braintree::GooglePayDetails._new(:gateway, {:consumer => "No"})
|
|
16
|
+
expect(card.consumer).to eq("No")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "initializes corporate correctly" do
|
|
20
|
+
card = Braintree::GooglePayDetails._new(:gateway, {:corporate => "No"})
|
|
21
|
+
expect(card.corporate).to eq("No")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "initializes purchase correctly" do
|
|
25
|
+
card = Braintree::GooglePayDetails._new(:gateway, {:purchase => "No"})
|
|
26
|
+
expect(card.purchase).to eq("No")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "payment_account_reference" do
|
|
30
|
+
it "returns the payment account reference when present" do
|
|
31
|
+
details = Braintree::Transaction::GooglePayDetails.new(
|
|
32
|
+
:payment_account_reference => "V0010013019339005665779448477",
|
|
33
|
+
)
|
|
34
|
+
expect(details.payment_account_reference).to eq("V0010013019339005665779448477")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|