braintree 4.34.0 → 4.36.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 +7 -0
- data/lib/braintree/apple_pay_gateway.rb +43 -0
- data/lib/braintree/base_module.rb +9 -0
- data/lib/braintree/credit_card_verification.rb +2 -0
- data/lib/braintree/customer.rb +2 -2
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/error_codes.rb +20 -0
- data/lib/braintree/gateway.rb +4 -0
- data/lib/braintree/graphql/inputs/billing_address_input.rb +34 -0
- data/lib/braintree/graphql/inputs/create_local_payment_context_input.rb +44 -0
- data/lib/braintree/graphql/inputs/payer_info_input.rb +38 -0
- data/lib/braintree/graphql/inputs/shipping_address_input.rb +34 -0
- data/lib/braintree/local_payment_context.rb +108 -0
- data/lib/braintree/local_payment_context_gateway.rb +132 -0
- data/lib/braintree/local_payment_type.rb +6 -0
- data/lib/braintree/merchant_gateway.rb +16 -16
- data/lib/braintree/monetary_amount.rb +24 -0
- data/lib/braintree/payment_instrument_type.rb +1 -0
- data/lib/braintree/payment_method_parser.rb +1 -0
- data/lib/braintree/successful_result.rb +1 -0
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +2 -0
- data/lib/braintree/transaction.rb +8 -2
- data/lib/braintree/transaction_gateway.rb +12 -5
- data/lib/braintree/transaction_search.rb +1 -0
- data/lib/braintree/validation_error_collection.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -0
- data/lib/braintree.rb +20 -3
- data/spec/integration/braintree/customer_spec.rb +550 -16
- data/spec/integration/braintree/http_spec.rb +1 -1
- data/spec/integration/braintree/local_payment_context_spec.rb +168 -0
- data/spec/integration/braintree/merchant_spec.rb +5 -169
- data/spec/integration/braintree/payment_method_spec.rb +174 -1
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +1 -1
- data/spec/integration/braintree/test_transaction_spec.rb +6 -6
- data/spec/integration/braintree/transaction_idempotency_spec.rb +320 -0
- data/spec/integration/braintree/transaction_search_spec.rb +3 -2
- data/spec/integration/braintree/transaction_spec.rb +91 -0
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +4 -100
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/unit/braintree/customer_spec.rb +67 -1
- data/spec/unit/braintree/graphql/billing_address_input_spec.rb +68 -0
- data/spec/unit/braintree/graphql/create_local_payment_context_input_spec.rb +63 -0
- data/spec/unit/braintree/graphql/monetary_amount_input_spec.rb +55 -0
- data/spec/unit/braintree/graphql/payer_info_input_spec.rb +92 -0
- data/spec/unit/braintree/local_payment_context_gateway_spec.rb +149 -0
- data/spec/unit/braintree/local_payment_context_spec.rb +141 -0
- data/spec/unit/braintree/monetary_amount_spec.rb +34 -0
- data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +7 -7
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +7 -7
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +6 -6
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +6 -6
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +4 -4
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +6 -6
- data/spec/unit/braintree/transaction_gateway_spec.rb +5 -3
- data/spec/unit/braintree/transaction_spec.rb +31 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +1 -0
- data/spec/unit/credit_card_details_spec.rb +6 -6
- data/spec/unit/spec_helper.rb +9 -0
- metadata +23 -6
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Braintree::LocalPaymentContextGateway do
|
|
5
|
+
before(:each) { skip("Pending until test data is fixed.") }
|
|
6
|
+
let(:gateway) do
|
|
7
|
+
Braintree::Gateway.new(
|
|
8
|
+
:environment => :development,
|
|
9
|
+
:merchant_id => "pwpp_multi_account_merchant",
|
|
10
|
+
:public_key => "pwpp_multi_account_merchant_public_key",
|
|
11
|
+
:private_key => "pwpp_multi_account_merchant_private_key",
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "create" do
|
|
16
|
+
it "can create MBWAY payment context" do
|
|
17
|
+
input = Braintree::CreateLocalPaymentContextInput.new(
|
|
18
|
+
amount: {
|
|
19
|
+
value: "10.00",
|
|
20
|
+
currency_code: "EUR"
|
|
21
|
+
},
|
|
22
|
+
type: Braintree::LocalPaymentType::MBWAY,
|
|
23
|
+
payer_info: {
|
|
24
|
+
given_name: "John",
|
|
25
|
+
surname: "Doe",
|
|
26
|
+
phone_number: "912345678",
|
|
27
|
+
phone_country_code: "351"
|
|
28
|
+
},
|
|
29
|
+
shipping_address: {
|
|
30
|
+
street_address: "123 Main St",
|
|
31
|
+
extended_address: "Apt 4B",
|
|
32
|
+
locality: "Lisbon",
|
|
33
|
+
region: "Lisboa",
|
|
34
|
+
postal_code: "1000-001",
|
|
35
|
+
country_code: "PT"
|
|
36
|
+
},
|
|
37
|
+
return_url: "https://example.com/return",
|
|
38
|
+
cancel_url: "https://example.com/cancel",
|
|
39
|
+
merchant_account_id: "eur_pwpp_multi_account_merchant_account",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
result = gateway.local_payment_context.create(input)
|
|
43
|
+
|
|
44
|
+
expect(result.success?).to eq(true)
|
|
45
|
+
expect(result.payment_context).not_to be_nil
|
|
46
|
+
expect(result.payment_context.id).not_to be_nil
|
|
47
|
+
expect(result.payment_context.legacy_id).not_to be_nil
|
|
48
|
+
expect(result.payment_context.type).to eq("MBWAY")
|
|
49
|
+
expect(result.payment_context.amount.value).to eq("10.00")
|
|
50
|
+
expect(result.payment_context.amount.currency_code).to eq("EUR")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "can create CRYPTO payment context" do
|
|
54
|
+
input = Braintree::CreateLocalPaymentContextInput.new(
|
|
55
|
+
amount: {
|
|
56
|
+
value: "25.00",
|
|
57
|
+
currency_code: "USD"
|
|
58
|
+
},
|
|
59
|
+
type: Braintree::LocalPaymentType::CRYPTO,
|
|
60
|
+
payer_info: {
|
|
61
|
+
given_name: "John",
|
|
62
|
+
surname: "Doe",
|
|
63
|
+
email: "john.doe@example.com"
|
|
64
|
+
},
|
|
65
|
+
return_url: "https://example.com/return",
|
|
66
|
+
cancel_url: "https://example.com/cancel",
|
|
67
|
+
merchant_account_id: "usd_pwpp_multi_account_merchant_account",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
result = gateway.local_payment_context.create(input)
|
|
71
|
+
|
|
72
|
+
expect(result.success?).to eq(true)
|
|
73
|
+
expect(result.payment_context).not_to be_nil
|
|
74
|
+
expect(result.payment_context.id).not_to be_nil
|
|
75
|
+
expect(result.payment_context.legacy_id).not_to be_nil
|
|
76
|
+
expect(result.payment_context.type).to eq("CRYPTO")
|
|
77
|
+
expect(result.payment_context.amount.value).to eq("25.00")
|
|
78
|
+
expect(result.payment_context.amount.currency_code).to eq("USD")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "can create payment context with only required fields" do
|
|
82
|
+
input = Braintree::CreateLocalPaymentContextInput.new(
|
|
83
|
+
amount: {
|
|
84
|
+
value: "15.00",
|
|
85
|
+
currency_code: "USD"
|
|
86
|
+
},
|
|
87
|
+
type: Braintree::LocalPaymentType::CRYPTO,
|
|
88
|
+
payer_info: {
|
|
89
|
+
given_name: "Jane",
|
|
90
|
+
surname: "Smith"
|
|
91
|
+
},
|
|
92
|
+
return_url: "https://example.com/return",
|
|
93
|
+
cancel_url: "https://example.com/cancel",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
result = gateway.local_payment_context.create(input)
|
|
97
|
+
|
|
98
|
+
expect(result.success?).to eq(true)
|
|
99
|
+
expect(result.payment_context).not_to be_nil
|
|
100
|
+
expect(result.payment_context.id).not_to be_nil
|
|
101
|
+
expect(result.payment_context.legacy_id).not_to be_nil
|
|
102
|
+
expect(result.payment_context.type).to eq("CRYPTO")
|
|
103
|
+
expect(result.payment_context.amount.value).to eq("15.00")
|
|
104
|
+
expect(result.payment_context.amount.currency_code).to eq("USD")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "returns error for invalid input" do
|
|
108
|
+
input = Braintree::CreateLocalPaymentContextInput.new(
|
|
109
|
+
amount: {
|
|
110
|
+
value: "invalid",
|
|
111
|
+
currency_code: "EUR"
|
|
112
|
+
},
|
|
113
|
+
type: Braintree::LocalPaymentType::MBWAY,
|
|
114
|
+
payer_info: {
|
|
115
|
+
given_name: "John",
|
|
116
|
+
surname: "Doe"
|
|
117
|
+
},
|
|
118
|
+
return_url: "https://example.com/return",
|
|
119
|
+
cancel_url: "https://example.com/cancel",
|
|
120
|
+
merchant_account_id: "eur_pwpp_multi_account_merchant_account",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
result = gateway.local_payment_context.create(input)
|
|
124
|
+
|
|
125
|
+
expect(result.success?).to eq(false)
|
|
126
|
+
expect(result.errors.size).to be > 0
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe "find" do
|
|
131
|
+
it "can find a payment context by ID" do
|
|
132
|
+
input = Braintree::CreateLocalPaymentContextInput.new(
|
|
133
|
+
amount: {
|
|
134
|
+
value: "10.00",
|
|
135
|
+
currency_code: "EUR"
|
|
136
|
+
},
|
|
137
|
+
type: Braintree::LocalPaymentType::MBWAY,
|
|
138
|
+
payer_info: {
|
|
139
|
+
given_name: "John",
|
|
140
|
+
surname: "Doe",
|
|
141
|
+
phone_number: "912345678",
|
|
142
|
+
phone_country_code: "351"
|
|
143
|
+
},
|
|
144
|
+
return_url: "https://example.com/return",
|
|
145
|
+
cancel_url: "https://example.com/cancel",
|
|
146
|
+
merchant_account_id: "eur_pwpp_multi_account_merchant_account",
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
create_result = gateway.local_payment_context.create(input)
|
|
150
|
+
expect(create_result.success?).to eq(true)
|
|
151
|
+
|
|
152
|
+
payment_context_id = create_result.payment_context.id
|
|
153
|
+
find_result = gateway.local_payment_context.find(payment_context_id)
|
|
154
|
+
|
|
155
|
+
expect(find_result.success?).to eq(true)
|
|
156
|
+
expect(find_result.payment_context).not_to be_nil
|
|
157
|
+
expect(find_result.payment_context.id).to eq(payment_context_id)
|
|
158
|
+
expect(find_result.payment_context.legacy_id).not_to be_nil
|
|
159
|
+
expect(find_result.payment_context.type).to eq("MBWAY")
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "raises NotFoundError for non-existent ID" do
|
|
163
|
+
expect {
|
|
164
|
+
gateway.local_payment_context.find("non-existent-id-123")
|
|
165
|
+
}.to raise_error(Braintree::NotFoundError)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -1,186 +1,22 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
|
3
3
|
describe Braintree::MerchantGateway do
|
|
4
|
+
# NEXT_MAJOR_VERSION remove this test
|
|
4
5
|
describe "create" do
|
|
5
|
-
|
|
6
|
+
it "raises a server error because the endpoint has been disabled" do
|
|
6
7
|
gateway = Braintree::Gateway.new(
|
|
7
8
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
8
9
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
9
10
|
:logger => Logger.new("/dev/null"),
|
|
10
11
|
)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
:country_code_alpha3 => "GBR",
|
|
15
|
-
:payment_methods => ["credit_card", "paypal"],
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
expect(result).to be_success
|
|
19
|
-
|
|
20
|
-
merchant = result.merchant
|
|
21
|
-
expect(merchant.id).not_to be_nil
|
|
22
|
-
expect(merchant.email).to eq("name@email.com")
|
|
23
|
-
expect(merchant.company_name).to eq("name@email.com")
|
|
24
|
-
expect(merchant.country_code_alpha3).to eq("GBR")
|
|
25
|
-
expect(merchant.country_code_alpha2).to eq("GB")
|
|
26
|
-
expect(merchant.country_code_numeric).to eq("826")
|
|
27
|
-
expect(merchant.country_name).to eq("United Kingdom")
|
|
28
|
-
|
|
29
|
-
credentials = result.credentials
|
|
30
|
-
expect(credentials.access_token).not_to be_nil
|
|
31
|
-
expect(credentials.refresh_token).not_to be_nil
|
|
32
|
-
expect(credentials.expires_at).not_to be_nil
|
|
33
|
-
expect(credentials.token_type).to eq("bearer")
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "gives an error when using invalid payment_methods" do
|
|
37
|
-
gateway = Braintree::Gateway.new(
|
|
38
|
-
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
39
|
-
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
40
|
-
:logger => Logger.new("/dev/null"),
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
result = gateway.merchant.create(
|
|
44
|
-
:email => "name@email.com",
|
|
45
|
-
:country_code_alpha3 => "GBR",
|
|
46
|
-
:payment_methods => ["fake_money"],
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
expect(result).not_to be_success
|
|
50
|
-
errors = result.errors.for(:merchant).on(:payment_methods)
|
|
51
|
-
|
|
52
|
-
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::PaymentMethodsAreInvalid)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
context "credentials" do
|
|
56
|
-
around(:each) do |example|
|
|
57
|
-
old_merchant_id_value = Braintree::Configuration.merchant_id
|
|
58
|
-
example.run
|
|
59
|
-
Braintree::Configuration.merchant_id = old_merchant_id_value
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
xit "allows using a merchant_id passed in through Gateway" do
|
|
63
|
-
Braintree::Configuration.merchant_id = nil
|
|
64
|
-
|
|
65
|
-
gateway = Braintree::Gateway.new(
|
|
66
|
-
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
67
|
-
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
68
|
-
:merchant_id => "integration_merchant_id",
|
|
69
|
-
:logger => Logger.new("/dev/null"),
|
|
70
|
-
)
|
|
71
|
-
result = gateway.merchant.create(
|
|
13
|
+
expect do
|
|
14
|
+
gateway.merchant.create(
|
|
72
15
|
:email => "name@email.com",
|
|
73
16
|
:country_code_alpha3 => "GBR",
|
|
74
17
|
:payment_methods => ["credit_card", "paypal"],
|
|
75
18
|
)
|
|
76
|
-
|
|
77
|
-
expect(result).to be_success
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context "multiple currencies" do
|
|
82
|
-
before(:each) do
|
|
83
|
-
@gateway = Braintree::Gateway.new(
|
|
84
|
-
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
85
|
-
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
86
|
-
:logger => Logger.new("/dev/null"),
|
|
87
|
-
)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
xit "creates an EU multi currency merchant for paypal and credit_card" do
|
|
91
|
-
result = @gateway.merchant.create(
|
|
92
|
-
:email => "name@email.com",
|
|
93
|
-
:country_code_alpha3 => "GBR",
|
|
94
|
-
:payment_methods => ["credit_card", "paypal"],
|
|
95
|
-
:currencies => ["GBP", "USD"],
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
merchant = result.merchant
|
|
99
|
-
expect(merchant.id).not_to be_nil
|
|
100
|
-
expect(merchant.email).to eq("name@email.com")
|
|
101
|
-
expect(merchant.company_name).to eq("name@email.com")
|
|
102
|
-
expect(merchant.country_code_alpha3).to eq("GBR")
|
|
103
|
-
expect(merchant.country_code_alpha2).to eq("GB")
|
|
104
|
-
expect(merchant.country_code_numeric).to eq("826")
|
|
105
|
-
expect(merchant.country_name).to eq("United Kingdom")
|
|
106
|
-
|
|
107
|
-
credentials = result.credentials
|
|
108
|
-
expect(credentials.access_token).not_to be_nil
|
|
109
|
-
expect(credentials.refresh_token).not_to be_nil
|
|
110
|
-
expect(credentials.expires_at).not_to be_nil
|
|
111
|
-
expect(credentials.token_type).to eq("bearer")
|
|
112
|
-
|
|
113
|
-
merchant_accounts = merchant.merchant_accounts
|
|
114
|
-
expect(merchant_accounts.count).to eq(2)
|
|
115
|
-
|
|
116
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
|
117
|
-
expect(merchant_account.default).to eq(true)
|
|
118
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
|
119
|
-
|
|
120
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
|
121
|
-
expect(merchant_account.default).to eq(false)
|
|
122
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
xit "creates a paypal-only merchant that accepts multiple currencies" do
|
|
127
|
-
result = @gateway.merchant.create(
|
|
128
|
-
:email => "name@email.com",
|
|
129
|
-
:country_code_alpha3 => "GBR",
|
|
130
|
-
:payment_methods => ["paypal"],
|
|
131
|
-
:currencies => ["GBP", "USD"],
|
|
132
|
-
:paypal_account => {
|
|
133
|
-
:client_id => "paypal_client_id",
|
|
134
|
-
:client_secret => "paypal_client_secret",
|
|
135
|
-
},
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
expect(result).to be_success
|
|
139
|
-
|
|
140
|
-
merchant = result.merchant
|
|
141
|
-
expect(merchant.id).not_to be_nil
|
|
142
|
-
expect(merchant.email).to eq("name@email.com")
|
|
143
|
-
expect(merchant.company_name).to eq("name@email.com")
|
|
144
|
-
expect(merchant.country_code_alpha3).to eq("GBR")
|
|
145
|
-
expect(merchant.country_code_alpha2).to eq("GB")
|
|
146
|
-
expect(merchant.country_code_numeric).to eq("826")
|
|
147
|
-
expect(merchant.country_name).to eq("United Kingdom")
|
|
148
|
-
|
|
149
|
-
credentials = result.credentials
|
|
150
|
-
expect(credentials.access_token).not_to be_nil
|
|
151
|
-
expect(credentials.refresh_token).not_to be_nil
|
|
152
|
-
expect(credentials.expires_at).not_to be_nil
|
|
153
|
-
expect(credentials.token_type).to eq("bearer")
|
|
154
|
-
|
|
155
|
-
merchant_accounts = merchant.merchant_accounts
|
|
156
|
-
expect(merchant_accounts.count).to eq(2)
|
|
157
|
-
|
|
158
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
|
159
|
-
expect(merchant_account.default).to eq(false)
|
|
160
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
|
161
|
-
|
|
162
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
|
163
|
-
expect(merchant_account.default).to eq(true)
|
|
164
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it "returns error if invalid currency is passed" do
|
|
168
|
-
result = @gateway.merchant.create(
|
|
169
|
-
:email => "name@email.com",
|
|
170
|
-
:country_code_alpha3 => "GBR",
|
|
171
|
-
:payment_methods => ["paypal"],
|
|
172
|
-
:currencies => ["FAKE", "GBP"],
|
|
173
|
-
:paypal_account => {
|
|
174
|
-
:client_id => "paypal_client_id",
|
|
175
|
-
:client_secret => "paypal_client_secret",
|
|
176
|
-
},
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
expect(result).not_to be_success
|
|
180
|
-
errors = result.errors.for(:merchant).on(:currencies)
|
|
181
|
-
|
|
182
|
-
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::CurrenciesAreInvalid)
|
|
183
|
-
end
|
|
19
|
+
end.to raise_error(Braintree::ServerError)
|
|
184
20
|
end
|
|
185
21
|
end
|
|
186
22
|
|
|
@@ -813,7 +813,7 @@ describe Braintree::PaymentMethod do
|
|
|
813
813
|
expect(update_result.payment_method.verification.credit_card[:account_type]).to eq("credit")
|
|
814
814
|
end
|
|
815
815
|
|
|
816
|
-
|
|
816
|
+
xit "updates the credit card with account_type debit" do
|
|
817
817
|
customer = Braintree::Customer.create!
|
|
818
818
|
credit_card = Braintree::CreditCard.create!(
|
|
819
819
|
:cardholder_name => "Original Holder",
|
|
@@ -1020,6 +1020,179 @@ describe Braintree::PaymentMethod do
|
|
|
1020
1020
|
end
|
|
1021
1021
|
end
|
|
1022
1022
|
|
|
1023
|
+
it "does card verification for ApplePay" do
|
|
1024
|
+
customer = Braintree::Customer.create!
|
|
1025
|
+
result = Braintree::PaymentMethod.create(
|
|
1026
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1027
|
+
:customer_id => customer.id,
|
|
1028
|
+
:options => {
|
|
1029
|
+
:verify_card => true,
|
|
1030
|
+
:verification_amount => "1.00",
|
|
1031
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
|
1032
|
+
},
|
|
1033
|
+
)
|
|
1034
|
+
expect(result).to be_success
|
|
1035
|
+
verification = result.payment_method.verification
|
|
1036
|
+
|
|
1037
|
+
expect(verification.merchant_account_id).to eq(SpecHelper::NonDefaultMerchantAccountId)
|
|
1038
|
+
expect(verification.amount).to eq(BigDecimal("1.00"))
|
|
1039
|
+
end
|
|
1040
|
+
|
|
1041
|
+
it "verifies the apple pay card when only verify_card set to true is provided" do
|
|
1042
|
+
customer = Braintree::Customer.create!
|
|
1043
|
+
|
|
1044
|
+
result = Braintree::PaymentMethod.create(
|
|
1045
|
+
:customer_id => customer.id,
|
|
1046
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1047
|
+
:options => {
|
|
1048
|
+
:verify_card => true,
|
|
1049
|
+
},
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
expect(result).to be_success
|
|
1053
|
+
expect(result.payment_method).to be_a(Braintree::ApplePayCard)
|
|
1054
|
+
verification = result.payment_method.verification
|
|
1055
|
+
expect(verification).not_to be_nil
|
|
1056
|
+
end
|
|
1057
|
+
|
|
1058
|
+
it "does not verify the apple pay card when verify_card is false" do
|
|
1059
|
+
customer = Braintree::Customer.create!
|
|
1060
|
+
|
|
1061
|
+
result = Braintree::PaymentMethod.create(
|
|
1062
|
+
:customer_id => customer.id,
|
|
1063
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1064
|
+
:options => {
|
|
1065
|
+
:verify_card => false,
|
|
1066
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
|
1067
|
+
:verification_amount => "10.00",
|
|
1068
|
+
},
|
|
1069
|
+
)
|
|
1070
|
+
|
|
1071
|
+
expect(result).to be_success
|
|
1072
|
+
expect(result.payment_method).to be_a(Braintree::ApplePayCard)
|
|
1073
|
+
|
|
1074
|
+
verification = result.payment_method.verification
|
|
1075
|
+
expect(verification).to be_nil
|
|
1076
|
+
end
|
|
1077
|
+
|
|
1078
|
+
it "errors when verification amount is negative for apple pay" do
|
|
1079
|
+
customer = Braintree::Customer.create!
|
|
1080
|
+
result = Braintree::PaymentMethod.create(
|
|
1081
|
+
payment_method_nonce: Braintree::Test::Nonce::ApplePayVisa,
|
|
1082
|
+
:customer_id => customer.id,
|
|
1083
|
+
options: {
|
|
1084
|
+
verify_card: true,
|
|
1085
|
+
verification_amount: "-1.00",
|
|
1086
|
+
},
|
|
1087
|
+
)
|
|
1088
|
+
|
|
1089
|
+
expect(result).not_to be_success
|
|
1090
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountCannotBeNegative
|
|
1091
|
+
end
|
|
1092
|
+
|
|
1093
|
+
it "errors when verification amount format is invalid for apple pay" do
|
|
1094
|
+
customer = Braintree::Customer.create!
|
|
1095
|
+
|
|
1096
|
+
result = Braintree::PaymentMethod.create(
|
|
1097
|
+
:customer_id => customer.id,
|
|
1098
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1099
|
+
:options => {
|
|
1100
|
+
:verify_card => true,
|
|
1101
|
+
:verification_amount => "0.001",
|
|
1102
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
|
1103
|
+
},
|
|
1104
|
+
)
|
|
1105
|
+
|
|
1106
|
+
expect(result).to_not be_success
|
|
1107
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountFormatIsInvalid
|
|
1108
|
+
end
|
|
1109
|
+
|
|
1110
|
+
it "errors when verification amount is not supported for processor on apple pay" do
|
|
1111
|
+
customer = Braintree::Customer.create!
|
|
1112
|
+
|
|
1113
|
+
result = Braintree::PaymentMethod.create(
|
|
1114
|
+
:customer_id => customer.id,
|
|
1115
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1116
|
+
:options => {
|
|
1117
|
+
:verify_card => true,
|
|
1118
|
+
:verification_amount => "0.01",
|
|
1119
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
|
1120
|
+
},
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
expect(result).to_not be_success
|
|
1124
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountNotSupportedByProcessor
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
it "errors when verification amount is too large on apple pay" do
|
|
1128
|
+
customer = Braintree::Customer.create!
|
|
1129
|
+
|
|
1130
|
+
result = Braintree::PaymentMethod.create(
|
|
1131
|
+
:customer_id => customer.id,
|
|
1132
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1133
|
+
:options => {
|
|
1134
|
+
:verify_card => true,
|
|
1135
|
+
:verification_amount => ((2**31) / 100.0).to_s,
|
|
1136
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
|
1137
|
+
},
|
|
1138
|
+
)
|
|
1139
|
+
|
|
1140
|
+
expect(result).to_not be_success
|
|
1141
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountIsTooLarge
|
|
1142
|
+
end
|
|
1143
|
+
|
|
1144
|
+
it "errors when verification merchant account is invalid" do
|
|
1145
|
+
customer = Braintree::Customer.create!
|
|
1146
|
+
|
|
1147
|
+
result = Braintree::PaymentMethod.create(
|
|
1148
|
+
:customer_id => customer.id,
|
|
1149
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1150
|
+
:options => {
|
|
1151
|
+
:verify_card => true,
|
|
1152
|
+
:verification_amount => "10.00",
|
|
1153
|
+
:verification_merchant_account_id => "BAD_MERCHANT_ACCOUNT",
|
|
1154
|
+
},
|
|
1155
|
+
)
|
|
1156
|
+
|
|
1157
|
+
expect(result).to_not be_success
|
|
1158
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIdIsInvalid
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
it "errors when verification merchant account is suspended" do
|
|
1162
|
+
customer = Braintree::Customer.create!
|
|
1163
|
+
|
|
1164
|
+
result = Braintree::PaymentMethod.create(
|
|
1165
|
+
:customer_id => customer.id,
|
|
1166
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1167
|
+
:options => {
|
|
1168
|
+
:verify_card => true,
|
|
1169
|
+
:verification_amount => "10.00",
|
|
1170
|
+
:verification_merchant_account_id => SpecHelper::SuspendedAccount,
|
|
1171
|
+
},
|
|
1172
|
+
)
|
|
1173
|
+
|
|
1174
|
+
expect(result).to_not be_success
|
|
1175
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[1].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIsSuspended
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
it "errors when account_type not supported by merchant on apple_pay" do
|
|
1179
|
+
customer = Braintree::Customer.create!
|
|
1180
|
+
|
|
1181
|
+
result = Braintree::PaymentMethod.create(
|
|
1182
|
+
:customer_id => customer.id,
|
|
1183
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
1184
|
+
:options => {
|
|
1185
|
+
:verify_card => true,
|
|
1186
|
+
:verification_amount => "10.00",
|
|
1187
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
|
1188
|
+
:verification_account_type => "credit",
|
|
1189
|
+
},
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
expect(result).to_not be_success
|
|
1193
|
+
expect(result.errors.for(:apple_pay).for(:options).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAccountTypeNotSupported
|
|
1194
|
+
end
|
|
1195
|
+
|
|
1023
1196
|
context "verification_currency_iso_code" do
|
|
1024
1197
|
it "validates verification_currency_iso_code against currency configured in default merchant account" do
|
|
1025
1198
|
nonce = nonce_for_new_payment_method(
|
|
@@ -96,7 +96,7 @@ describe Braintree::PaymentMethod do
|
|
|
96
96
|
expect(us_bank_account.routing_number).to eq("123456789")
|
|
97
97
|
expect(us_bank_account.last_4).to eq("0000")
|
|
98
98
|
expect(us_bank_account.account_type).to eq("checking")
|
|
99
|
-
expect(us_bank_account.account_holder_name).to eq("
|
|
99
|
+
expect(us_bank_account.account_holder_name).to eq("Marty McFly")
|
|
100
100
|
expect(us_bank_account.bank_name).to match(/Wells Fargo/)
|
|
101
101
|
expect(us_bank_account.default).to eq(true)
|
|
102
102
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
@@ -6,7 +6,7 @@ describe Braintree::TestTransaction do
|
|
|
6
6
|
it "changes transaction status to settled" do
|
|
7
7
|
sale_result = Braintree::Transaction.sale(
|
|
8
8
|
:amount => "100",
|
|
9
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
9
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
10
10
|
:options => {
|
|
11
11
|
:submit_for_settlement => true
|
|
12
12
|
},
|
|
@@ -22,7 +22,7 @@ describe Braintree::TestTransaction do
|
|
|
22
22
|
it "changes transaction status to settlement_confirmed" do
|
|
23
23
|
sale_result = Braintree::Transaction.sale(
|
|
24
24
|
:amount => "100",
|
|
25
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
25
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
26
26
|
:options => {
|
|
27
27
|
:submit_for_settlement => true
|
|
28
28
|
},
|
|
@@ -38,7 +38,7 @@ describe Braintree::TestTransaction do
|
|
|
38
38
|
it "changes transaction status to settlement_declined" do
|
|
39
39
|
sale_result = Braintree::Transaction.sale(
|
|
40
40
|
:amount => "100",
|
|
41
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
41
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
42
42
|
:options => {
|
|
43
43
|
:submit_for_settlement => true
|
|
44
44
|
},
|
|
@@ -54,7 +54,7 @@ describe Braintree::TestTransaction do
|
|
|
54
54
|
it "changes transaction status to settlement_pending" do
|
|
55
55
|
sale_result = Braintree::Transaction.sale(
|
|
56
56
|
:amount => "100",
|
|
57
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
57
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
58
58
|
:options => {
|
|
59
59
|
:submit_for_settlement => true
|
|
60
60
|
},
|
|
@@ -70,7 +70,7 @@ describe Braintree::TestTransaction do
|
|
|
70
70
|
it "returns a validation error when invalid transition is specified" do
|
|
71
71
|
sale_result = Braintree::Transaction.sale(
|
|
72
72
|
:amount => "100",
|
|
73
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
73
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
74
74
|
)
|
|
75
75
|
expect(sale_result.success?).to eq(true)
|
|
76
76
|
|
|
@@ -110,7 +110,7 @@ describe Braintree::TestTransaction do
|
|
|
110
110
|
|
|
111
111
|
sale_result = transaction_gateway.sale(
|
|
112
112
|
:amount => "100",
|
|
113
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
|
113
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
114
114
|
)
|
|
115
115
|
testing_gateway.settle(sale_result.transaction.id)
|
|
116
116
|
end
|