braintree 4.20.0 → 4.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/address.rb +1 -0
- data/lib/braintree/address_gateway.rb +3 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card_verification.rb +16 -12
- data/lib/braintree/customer.rb +3 -2
- data/lib/braintree/customer_gateway.rb +6 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/local_payment_completed.rb +4 -1
- data/lib/braintree/paypal_account.rb +2 -0
- data/lib/braintree/transaction/address_details.rb +1 -0
- data/lib/braintree/transaction/customer_details.rb +2 -1
- data/lib/braintree/transaction/package_details.rb +4 -1
- data/lib/braintree/transaction.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +55 -47
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +2 -0
- data/lib/braintree/webhook_testing_gateway.rb +22 -1
- data/spec/integration/braintree/address_spec.rb +6 -0
- data/spec/integration/braintree/apple_pay_spec.rb +1 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +19 -0
- data/spec/integration/braintree/customer_spec.rb +6 -0
- data/spec/integration/braintree/merchant_account_spec.rb +2 -2
- data/spec/integration/braintree/merchant_spec.rb +17 -138
- data/spec/integration/braintree/package_tracking_spec.rb +34 -15
- data/spec/integration/braintree/payment_method_spec.rb +7 -1
- data/spec/integration/braintree/paypal_account_spec.rb +2 -0
- data/spec/integration/braintree/transaction_spec.rb +140 -1
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +2 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +13 -2
- data/spec/unit/braintree/customer_spec.rb +8 -0
- data/spec/unit/braintree/error_result_spec.rb +1 -1
- data/spec/unit/braintree/local_payment_completed_spec.rb +17 -5
- data/spec/unit/braintree/package_tracking_spec.rb +5 -2
- data/spec/unit/braintree/paypal_account_spec.rb +9 -0
- data/spec/unit/braintree/transaction/customer_details_spec.rb +2 -1
- data/spec/unit/braintree/transaction_gateway_spec.rb +54 -48
- data/spec/unit/braintree/webhook_notification_spec.rb +12 -0
- metadata +2 -2
@@ -11,7 +11,7 @@ describe Braintree::MerchantGateway do
|
|
11
11
|
|
12
12
|
result = gateway.merchant.create(
|
13
13
|
:email => "name@email.com",
|
14
|
-
:country_code_alpha3 => "
|
14
|
+
:country_code_alpha3 => "GBR",
|
15
15
|
:payment_methods => ["credit_card", "paypal"],
|
16
16
|
)
|
17
17
|
|
@@ -21,10 +21,10 @@ describe Braintree::MerchantGateway do
|
|
21
21
|
expect(merchant.id).not_to be_nil
|
22
22
|
expect(merchant.email).to eq("name@email.com")
|
23
23
|
expect(merchant.company_name).to eq("name@email.com")
|
24
|
-
expect(merchant.country_code_alpha3).to eq("
|
25
|
-
expect(merchant.country_code_alpha2).to eq("
|
26
|
-
expect(merchant.country_code_numeric).to eq("
|
27
|
-
expect(merchant.country_name).to eq("United
|
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
28
|
|
29
29
|
credentials = result.credentials
|
30
30
|
expect(credentials.access_token).not_to be_nil
|
@@ -42,7 +42,7 @@ describe Braintree::MerchantGateway do
|
|
42
42
|
|
43
43
|
result = gateway.merchant.create(
|
44
44
|
:email => "name@email.com",
|
45
|
-
:country_code_alpha3 => "
|
45
|
+
:country_code_alpha3 => "GBR",
|
46
46
|
:payment_methods => ["fake_money"],
|
47
47
|
)
|
48
48
|
|
@@ -70,7 +70,7 @@ describe Braintree::MerchantGateway do
|
|
70
70
|
)
|
71
71
|
result = gateway.merchant.create(
|
72
72
|
:email => "name@email.com",
|
73
|
-
:country_code_alpha3 => "
|
73
|
+
:country_code_alpha3 => "GBR",
|
74
74
|
:payment_methods => ["credit_card", "paypal"],
|
75
75
|
)
|
76
76
|
|
@@ -81,47 +81,12 @@ describe Braintree::MerchantGateway do
|
|
81
81
|
context "multiple currencies" do
|
82
82
|
before(:each) do
|
83
83
|
@gateway = Braintree::Gateway.new(
|
84
|
-
:client_id => "client_id$
|
85
|
-
:client_secret => "client_secret$
|
84
|
+
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
85
|
+
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
86
86
|
:logger => Logger.new("/dev/null"),
|
87
87
|
)
|
88
88
|
end
|
89
89
|
|
90
|
-
it "creates a US multi currency merchant for paypal and credit_card" do
|
91
|
-
result = @gateway.merchant.create(
|
92
|
-
:email => "name@email.com",
|
93
|
-
:country_code_alpha3 => "USA",
|
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("USA")
|
103
|
-
expect(merchant.country_code_alpha2).to eq("US")
|
104
|
-
expect(merchant.country_code_numeric).to eq("840")
|
105
|
-
expect(merchant.country_name).to eq("United States of America")
|
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 == "USD" }
|
117
|
-
expect(merchant_account.default).to eq(true)
|
118
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
119
|
-
|
120
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
121
|
-
expect(merchant_account.default).to eq(false)
|
122
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
123
|
-
end
|
124
|
-
|
125
90
|
it "creates an EU multi currency merchant for paypal and credit_card" do
|
126
91
|
result = @gateway.merchant.create(
|
127
92
|
:email => "name@email.com",
|
@@ -161,7 +126,7 @@ describe Braintree::MerchantGateway do
|
|
161
126
|
it "creates a paypal-only merchant that accepts multiple currencies" do
|
162
127
|
result = @gateway.merchant.create(
|
163
128
|
:email => "name@email.com",
|
164
|
-
:country_code_alpha3 => "
|
129
|
+
:country_code_alpha3 => "GBR",
|
165
130
|
:payment_methods => ["paypal"],
|
166
131
|
:currencies => ["GBP", "USD"],
|
167
132
|
:paypal_account => {
|
@@ -176,10 +141,10 @@ describe Braintree::MerchantGateway do
|
|
176
141
|
expect(merchant.id).not_to be_nil
|
177
142
|
expect(merchant.email).to eq("name@email.com")
|
178
143
|
expect(merchant.company_name).to eq("name@email.com")
|
179
|
-
expect(merchant.country_code_alpha3).to eq("
|
180
|
-
expect(merchant.country_code_alpha2).to eq("
|
181
|
-
expect(merchant.country_code_numeric).to eq("
|
182
|
-
expect(merchant.country_name).to eq("United
|
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")
|
183
148
|
|
184
149
|
credentials = result.credentials
|
185
150
|
expect(credentials.access_token).not_to be_nil
|
@@ -191,90 +156,18 @@ describe Braintree::MerchantGateway do
|
|
191
156
|
expect(merchant_accounts.count).to eq(2)
|
192
157
|
|
193
158
|
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
194
|
-
expect(merchant_account.default).to eq(
|
159
|
+
expect(merchant_account.default).to eq(false)
|
195
160
|
expect(merchant_account.currency_iso_code).to eq("USD")
|
196
161
|
|
197
162
|
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
198
|
-
expect(merchant_account.default).to eq(false)
|
199
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
200
|
-
end
|
201
|
-
|
202
|
-
it "allows creation of non-US merchant if onboarding application is internal" do
|
203
|
-
result = @gateway.merchant.create(
|
204
|
-
:email => "name@email.com",
|
205
|
-
:country_code_alpha3 => "JPN",
|
206
|
-
:payment_methods => ["paypal"],
|
207
|
-
:paypal_account => {
|
208
|
-
:client_id => "paypal_client_id",
|
209
|
-
:client_secret => "paypal_client_secret",
|
210
|
-
},
|
211
|
-
)
|
212
|
-
|
213
|
-
expect(result).to be_success
|
214
|
-
|
215
|
-
merchant = result.merchant
|
216
|
-
expect(merchant.id).not_to be_nil
|
217
|
-
expect(merchant.email).to eq("name@email.com")
|
218
|
-
expect(merchant.company_name).to eq("name@email.com")
|
219
|
-
expect(merchant.country_code_alpha3).to eq("JPN")
|
220
|
-
expect(merchant.country_code_alpha2).to eq("JP")
|
221
|
-
expect(merchant.country_code_numeric).to eq("392")
|
222
|
-
expect(merchant.country_name).to eq("Japan")
|
223
|
-
|
224
|
-
credentials = result.credentials
|
225
|
-
expect(credentials.access_token).not_to be_nil
|
226
|
-
expect(credentials.refresh_token).not_to be_nil
|
227
|
-
expect(credentials.expires_at).not_to be_nil
|
228
|
-
expect(credentials.token_type).to eq("bearer")
|
229
|
-
|
230
|
-
merchant_accounts = merchant.merchant_accounts
|
231
|
-
expect(merchant_accounts.count).to eq(1)
|
232
|
-
|
233
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "JPY" }
|
234
163
|
expect(merchant_account.default).to eq(true)
|
235
|
-
expect(merchant_account.currency_iso_code).to eq("
|
236
|
-
end
|
237
|
-
|
238
|
-
it "defaults to USD for non-US merchant if onboarding application is internal and country currency not supported" do
|
239
|
-
result = @gateway.merchant.create(
|
240
|
-
:email => "name@email.com",
|
241
|
-
:country_code_alpha3 => "YEM",
|
242
|
-
:payment_methods => ["paypal"],
|
243
|
-
:paypal_account => {
|
244
|
-
:client_id => "paypal_client_id",
|
245
|
-
:client_secret => "paypal_client_secret",
|
246
|
-
},
|
247
|
-
)
|
248
|
-
|
249
|
-
expect(result).to be_success
|
250
|
-
|
251
|
-
merchant = result.merchant
|
252
|
-
expect(merchant.id).not_to be_nil
|
253
|
-
expect(merchant.email).to eq("name@email.com")
|
254
|
-
expect(merchant.company_name).to eq("name@email.com")
|
255
|
-
expect(merchant.country_code_alpha3).to eq("YEM")
|
256
|
-
expect(merchant.country_code_alpha2).to eq("YE")
|
257
|
-
expect(merchant.country_code_numeric).to eq("887")
|
258
|
-
expect(merchant.country_name).to eq("Yemen")
|
259
|
-
|
260
|
-
credentials = result.credentials
|
261
|
-
expect(credentials.access_token).not_to be_nil
|
262
|
-
expect(credentials.refresh_token).not_to be_nil
|
263
|
-
expect(credentials.expires_at).not_to be_nil
|
264
|
-
expect(credentials.token_type).to eq("bearer")
|
265
|
-
|
266
|
-
merchant_accounts = merchant.merchant_accounts
|
267
|
-
expect(merchant_accounts.count).to eq(1)
|
268
|
-
|
269
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
270
|
-
expect(merchant_account.default).to eq(true)
|
271
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
164
|
+
expect(merchant_account.currency_iso_code).to eq("GBP")
|
272
165
|
end
|
273
166
|
|
274
167
|
it "returns error if invalid currency is passed" do
|
275
168
|
result = @gateway.merchant.create(
|
276
169
|
:email => "name@email.com",
|
277
|
-
:country_code_alpha3 => "
|
170
|
+
:country_code_alpha3 => "GBR",
|
278
171
|
:payment_methods => ["paypal"],
|
279
172
|
:currencies => ["FAKE", "GBP"],
|
280
173
|
:paypal_account => {
|
@@ -317,20 +210,6 @@ describe Braintree::MerchantGateway do
|
|
317
210
|
end
|
318
211
|
end
|
319
212
|
|
320
|
-
context "merchant has no processor connection supporting apple pay" do
|
321
|
-
before do
|
322
|
-
Braintree::Configuration.merchant_id = "forward_payment_method_merchant_id"
|
323
|
-
Braintree::Configuration.public_key = "forward_payment_method_public_key"
|
324
|
-
Braintree::Configuration.private_key = "forward_payment_method_private_key"
|
325
|
-
end
|
326
|
-
|
327
|
-
it "returns a validation error" do
|
328
|
-
result = Braintree::Merchant.provision_raw_apple_pay
|
329
|
-
expect(result).not_to be_success
|
330
|
-
expect(result.errors.for(:apple_pay).first.code).to eq(Braintree::ErrorCodes::ApplePay::ApplePayCardsAreNotAccepted)
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
213
|
def _save_config
|
335
214
|
@original_config = {
|
336
215
|
:merchant_id => Braintree::Configuration.merchant_id,
|
@@ -1,18 +1,17 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
2
3
|
|
4
|
+
# NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
|
3
5
|
describe Braintree::Transaction do
|
4
6
|
describe "self.package_tracking" do
|
7
|
+
let(:customer) { Braintree::Customer.create! }
|
5
8
|
it "returns validation error message from gateway api" do
|
6
|
-
# Create Transaction
|
7
9
|
result = Braintree::Transaction.sale(
|
8
10
|
:amount => "100",
|
11
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
9
12
|
:options => {
|
10
13
|
:submit_for_settlement => true
|
11
14
|
},
|
12
|
-
:paypal_account => {
|
13
|
-
:payer_id => "fake-payer-id",
|
14
|
-
:payment_id => "fake-payment-id",
|
15
|
-
},
|
16
15
|
)
|
17
16
|
|
18
17
|
expect(result.success?).to eq(true)
|
@@ -27,17 +26,12 @@ describe Braintree::Transaction do
|
|
27
26
|
end
|
28
27
|
|
29
28
|
it "successfully calls gateway API and adds package tracking information" do
|
30
|
-
|
31
|
-
# Create Transaction
|
32
29
|
result = Braintree::Transaction.sale(
|
33
30
|
:amount => "100",
|
31
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
34
32
|
:options => {
|
35
33
|
:submit_for_settlement => true
|
36
34
|
},
|
37
|
-
:paypal_account => {
|
38
|
-
:payer_id => "fake-payer-id",
|
39
|
-
:payment_id => "fake-payment-id",
|
40
|
-
},
|
41
35
|
)
|
42
36
|
|
43
37
|
expect(result.success?).to eq(true)
|
@@ -77,7 +71,8 @@ describe Braintree::Transaction do
|
|
77
71
|
expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
|
78
72
|
expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
|
79
73
|
expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
80
|
-
|
74
|
+
expect(firstPackageResult.transaction.packages[0].paypal_tracker_id).to be_nil
|
75
|
+
expect(firstPackageResult.transaction.packages[0].paypal_tracking_id).to be_nil
|
81
76
|
|
82
77
|
# Create second package with 1 product
|
83
78
|
secondPackageResult = Braintree::Transaction.package_tracking(
|
@@ -102,10 +97,34 @@ describe Braintree::Transaction do
|
|
102
97
|
expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
|
103
98
|
expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
|
104
99
|
expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
100
|
+
expect(secondPackageResult.transaction.packages[1].paypal_tracker_id).to be_nil
|
101
|
+
expect(secondPackageResult.transaction.packages[1].paypal_tracking_id).to be_nil
|
105
102
|
|
106
103
|
# Find transaction gives both packages
|
107
|
-
|
108
|
-
expect(
|
104
|
+
transaction = Braintree::Transaction.find(result.transaction.id)
|
105
|
+
expect(transaction.packages.length).to eq(2)
|
106
|
+
expect(transaction.packages[0].id).not_to be_nil
|
107
|
+
expect(transaction.packages[0].carrier).to eq("UPS")
|
108
|
+
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
109
|
+
#In test environment, since we do not have jobstream setup paypal tracker id is going to be nil, this is just to access we could access it
|
110
|
+
expect(transaction.packages[0].paypal_tracker_id).to be_nil
|
111
|
+
expect(transaction.packages[0].paypal_tracking_id).to be_nil
|
112
|
+
|
113
|
+
expect(transaction.packages[1].id).not_to be_nil
|
114
|
+
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
115
|
+
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
116
|
+
expect(transaction.packages[1].paypal_tracker_id).to be_nil
|
117
|
+
expect(transaction.packages[1].paypal_tracking_id).to be_nil
|
118
|
+
end
|
119
|
+
|
120
|
+
it "retrieves paypal_tracker_id successfully" do
|
121
|
+
transaction = Braintree::Transaction.find("package_tracking_tx")
|
122
|
+
expect(transaction.packages.length).to eq(2)
|
123
|
+
expect(transaction.packages[0].paypal_tracker_id).to eq("paypal_tracker_id_1")
|
124
|
+
expect(transaction.packages[0].paypal_tracking_id).to be_nil
|
125
|
+
|
126
|
+
expect(transaction.packages[1].paypal_tracker_id).to eq("paypal_tracker_id_2")
|
127
|
+
expect(transaction.packages[1].paypal_tracking_id).to be_nil
|
109
128
|
end
|
110
129
|
end
|
111
|
-
end
|
130
|
+
end
|
@@ -453,7 +453,8 @@ describe Braintree::PaymentMethod do
|
|
453
453
|
:payment_method_nonce => nonce,
|
454
454
|
:customer_id => customer.id,
|
455
455
|
:billing_address => {
|
456
|
-
:street_address => "123 Abc Way"
|
456
|
+
:street_address => "123 Abc Way",
|
457
|
+
:international_phone => {:country_code => "1", :national_number => "3121234567"},
|
457
458
|
},
|
458
459
|
)
|
459
460
|
|
@@ -464,6 +465,8 @@ describe Braintree::PaymentMethod do
|
|
464
465
|
found_credit_card = Braintree::CreditCard.find(token)
|
465
466
|
expect(found_credit_card).not_to be_nil
|
466
467
|
expect(found_credit_card.billing_address.street_address).to eq("123 Abc Way")
|
468
|
+
expect(found_credit_card.billing_address.international_phone[:country_code]).to eq("1")
|
469
|
+
expect(found_credit_card.billing_address.international_phone[:national_number]).to eq("3121234567")
|
467
470
|
end
|
468
471
|
|
469
472
|
it "allows passing a billing address id outside of the nonce" do
|
@@ -1677,12 +1680,15 @@ describe Braintree::PaymentMethod do
|
|
1677
1680
|
)
|
1678
1681
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1679
1682
|
:billing_address => {
|
1683
|
+
:international_phone => {:country_code => "1", :national_number => "3121234567"},
|
1680
1684
|
:region => "IL",
|
1681
1685
|
:options => {:update_existing => true}
|
1682
1686
|
},
|
1683
1687
|
)
|
1684
1688
|
expect(update_result.success?).to eq(true)
|
1685
1689
|
updated_credit_card = update_result.payment_method
|
1690
|
+
expect(updated_credit_card.billing_address.international_phone[:country_code]).to eq("1")
|
1691
|
+
expect(updated_credit_card.billing_address.international_phone[:national_number]).to eq("3121234567")
|
1686
1692
|
expect(updated_credit_card.billing_address.region).to eq("IL")
|
1687
1693
|
expect(updated_credit_card.billing_address.street_address).to eq("123 Nigeria Ave")
|
1688
1694
|
expect(updated_credit_card.billing_address.id).to eq(credit_card.billing_address.id)
|
@@ -25,6 +25,8 @@ describe Braintree::PayPalAccount do
|
|
25
25
|
expect(paypal_account.created_at).not_to be_nil
|
26
26
|
expect(paypal_account.updated_at).not_to be_nil
|
27
27
|
expect(paypal_account.customer_id).to eq(customer.id)
|
28
|
+
expect(paypal_account.funding_source_description).to be_nil
|
29
|
+
expect(paypal_account.edit_paypal_vault_id).to be_nil
|
28
30
|
expect(paypal_account.revoked_at).to be_nil
|
29
31
|
end
|
30
32
|
|
@@ -718,6 +718,49 @@ describe Braintree::Transaction do
|
|
718
718
|
end
|
719
719
|
end
|
720
720
|
|
721
|
+
context "foreign_retailer" do
|
722
|
+
it "returns true when foreign_retailer param is true" do
|
723
|
+
result = Braintree::Transaction.create(
|
724
|
+
:type => "sale",
|
725
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
726
|
+
:credit_card => {
|
727
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
728
|
+
:expiration_date => "05/2025"
|
729
|
+
},
|
730
|
+
:foreign_retailer => true,
|
731
|
+
)
|
732
|
+
expect(result).to be_success
|
733
|
+
expect(result.transaction.foreign_retailer).to be_truthy
|
734
|
+
end
|
735
|
+
|
736
|
+
it "returns nil when foreign_retailer param is false" do
|
737
|
+
result = Braintree::Transaction.create(
|
738
|
+
:type => "sale",
|
739
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
740
|
+
:credit_card => {
|
741
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
742
|
+
:expiration_date => "05/2025"
|
743
|
+
},
|
744
|
+
:foreign_retailer => false,
|
745
|
+
)
|
746
|
+
expect(result).to be_success
|
747
|
+
expect(result.transaction.foreign_retailer).to be_nil
|
748
|
+
end
|
749
|
+
|
750
|
+
it "returns nil when foreign_retailer param is nil" do
|
751
|
+
result = Braintree::Transaction.create(
|
752
|
+
:type => "sale",
|
753
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
754
|
+
:credit_card => {
|
755
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
756
|
+
:expiration_date => "05/2025"
|
757
|
+
},
|
758
|
+
)
|
759
|
+
expect(result).to be_success
|
760
|
+
expect(result.transaction.foreign_retailer).to be_nil
|
761
|
+
end
|
762
|
+
end
|
763
|
+
|
721
764
|
it "returns a successful result if successful" do
|
722
765
|
result = Braintree::Transaction.create(
|
723
766
|
:type => "sale",
|
@@ -1110,7 +1153,7 @@ describe Braintree::Transaction do
|
|
1110
1153
|
)
|
1111
1154
|
result = gateway.merchant.create(
|
1112
1155
|
:email => "name@email.com",
|
1113
|
-
:country_code_alpha3 => "
|
1156
|
+
:country_code_alpha3 => "GBR",
|
1114
1157
|
:payment_methods => ["credit_card", "paypal"],
|
1115
1158
|
)
|
1116
1159
|
|
@@ -5219,6 +5262,7 @@ describe Braintree::Transaction do
|
|
5219
5262
|
:locality => "Chicago",
|
5220
5263
|
:region => "IL",
|
5221
5264
|
:phone_number => "122-555-1237",
|
5265
|
+
:international_phone => {:country_code => "1", :national_number => "3121234567"},
|
5222
5266
|
:postal_code => "60622",
|
5223
5267
|
:country_name => "United States of America"
|
5224
5268
|
},
|
@@ -5231,6 +5275,7 @@ describe Braintree::Transaction do
|
|
5231
5275
|
:locality => "Bartlett",
|
5232
5276
|
:region => "IL",
|
5233
5277
|
:phone_number => "122-555-1236",
|
5278
|
+
:international_phone => {:country_code => "1", :national_number => "3121234567"},
|
5234
5279
|
:postal_code => "60103",
|
5235
5280
|
:country_name => "United States of America",
|
5236
5281
|
:shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
|
@@ -5277,6 +5322,9 @@ describe Braintree::Transaction do
|
|
5277
5322
|
expect(transaction.billing_details.country_code_alpha2).to eq("US")
|
5278
5323
|
expect(transaction.billing_details.country_code_alpha3).to eq("USA")
|
5279
5324
|
expect(transaction.billing_details.country_code_numeric).to eq("840")
|
5325
|
+
expect(transaction.billing_details.phone_number).to eq("122-555-1237")
|
5326
|
+
expect(transaction.billing_details.international_phone[:country_code]).to eq("1")
|
5327
|
+
expect(transaction.billing_details.international_phone[:national_number]).to eq("3121234567")
|
5280
5328
|
expect(transaction.shipping_details.first_name).to eq("Andrew")
|
5281
5329
|
expect(transaction.shipping_details.last_name).to eq("Mason")
|
5282
5330
|
expect(transaction.shipping_details.company).to eq("Braintree")
|
@@ -5289,6 +5337,9 @@ describe Braintree::Transaction do
|
|
5289
5337
|
expect(transaction.shipping_details.country_code_alpha2).to eq("US")
|
5290
5338
|
expect(transaction.shipping_details.country_code_alpha3).to eq("USA")
|
5291
5339
|
expect(transaction.shipping_details.country_code_numeric).to eq("840")
|
5340
|
+
expect(transaction.shipping_details.phone_number).to eq("122-555-1236")
|
5341
|
+
expect(transaction.shipping_details.international_phone[:country_code]).to eq("1")
|
5342
|
+
expect(transaction.shipping_details.international_phone[:national_number]).to eq("3121234567")
|
5292
5343
|
end
|
5293
5344
|
|
5294
5345
|
it "allows merchant account to be specified" do
|
@@ -6579,6 +6630,39 @@ describe Braintree::Transaction do
|
|
6579
6630
|
result = Braintree::Transaction.submit_for_partial_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
|
6580
6631
|
expect(result.success?).to be_truthy
|
6581
6632
|
end
|
6633
|
+
|
6634
|
+
it "final_capture indicates the current partial_capture as final" do
|
6635
|
+
authorized_transaction = Braintree::Transaction.sale!(
|
6636
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6637
|
+
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
6638
|
+
:credit_card => {
|
6639
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6640
|
+
:expiration_date => "06/2009"
|
6641
|
+
},
|
6642
|
+
)
|
6643
|
+
|
6644
|
+
result1 = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
6645
|
+
expect(result1.success?).to eq(true)
|
6646
|
+
partial_settlement_transaction1 = result1.transaction
|
6647
|
+
expect(partial_settlement_transaction1.amount).to eq(100)
|
6648
|
+
expect(partial_settlement_transaction1.type).to eq(Braintree::Transaction::Type::Sale)
|
6649
|
+
expect(partial_settlement_transaction1.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
6650
|
+
expect(partial_settlement_transaction1.authorized_transaction_id).to eq(authorized_transaction.id)
|
6651
|
+
refreshed_authorized_transaction1 = Braintree::Transaction.find(authorized_transaction.id)
|
6652
|
+
expect(refreshed_authorized_transaction1.status).to eq(Braintree::Transaction::Status::SettlementPending)
|
6653
|
+
|
6654
|
+
options = {:final_capture => true}
|
6655
|
+
result2 = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, options)
|
6656
|
+
expect(result2.success?).to eq(true)
|
6657
|
+
partial_settlement_transaction2 = result2.transaction
|
6658
|
+
expect(partial_settlement_transaction2.amount).to eq(100)
|
6659
|
+
expect(partial_settlement_transaction2.type).to eq(Braintree::Transaction::Type::Sale)
|
6660
|
+
expect(partial_settlement_transaction2.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
6661
|
+
expect(partial_settlement_transaction2.authorized_transaction_id).to eq(authorized_transaction.id)
|
6662
|
+
|
6663
|
+
refreshed_authorized_transaction2 = Braintree::Transaction.find(authorized_transaction.id)
|
6664
|
+
expect(refreshed_authorized_transaction2.status).to eq(Braintree::Transaction::Status::SettlementPending)
|
6665
|
+
end
|
6582
6666
|
end
|
6583
6667
|
|
6584
6668
|
describe "self.submit_for_partial_settlement!" do
|
@@ -7851,4 +7935,59 @@ describe Braintree::Transaction do
|
|
7851
7935
|
expect(result.transaction.merchant_advice_code_text).to eq("New account information available")
|
7852
7936
|
end
|
7853
7937
|
end
|
7938
|
+
|
7939
|
+
context "Shipping Tax Amount" do
|
7940
|
+
it "accepts shipping-tax-amount field" do
|
7941
|
+
result = Braintree::Transaction.create(
|
7942
|
+
:type => "sale",
|
7943
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
7944
|
+
:amount => "10.00",
|
7945
|
+
:shipping_amount => "1.00",
|
7946
|
+
:shipping_tax_amount => "1.00",
|
7947
|
+
:discount_amount => "2.00",
|
7948
|
+
:ships_from_postal_code => "12345",
|
7949
|
+
)
|
7950
|
+
|
7951
|
+
expect(result.success?).to eq(true)
|
7952
|
+
expect(result.transaction.shipping_amount).to eq("1.00")
|
7953
|
+
expect(result.transaction.shipping_tax_amount).to eq("1.00")
|
7954
|
+
expect(result.transaction.discount_amount).to eq("2.00")
|
7955
|
+
expect(result.transaction.ships_from_postal_code).to eq("12345")
|
7956
|
+
end
|
7957
|
+
|
7958
|
+
it "submit for settlement succeeds when shipping tax amount is provided" do
|
7959
|
+
result = Braintree::Transaction.sale(
|
7960
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7961
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
7962
|
+
:credit_card => {
|
7963
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7964
|
+
:expiration_date => "05/2029"
|
7965
|
+
},
|
7966
|
+
)
|
7967
|
+
expect(result.success?).to eq(true)
|
7968
|
+
|
7969
|
+
result = Braintree::Transaction.submit_for_settlement(
|
7970
|
+
result.transaction.id,
|
7971
|
+
nil,
|
7972
|
+
:discount_amount => "2.00",
|
7973
|
+
:shipping_amount => "1.23",
|
7974
|
+
:shipping_tax_amount => "0.40",
|
7975
|
+
:ships_from_postal_code => "90210",
|
7976
|
+
:line_items => [
|
7977
|
+
{
|
7978
|
+
:quantity => 1,
|
7979
|
+
:unit_amount => 1,
|
7980
|
+
:name => "New line item",
|
7981
|
+
:kind => "debit",
|
7982
|
+
:total_amount => "18.00",
|
7983
|
+
:discount_amount => "12.00",
|
7984
|
+
:tax_amount => "0",
|
7985
|
+
},
|
7986
|
+
],
|
7987
|
+
)
|
7988
|
+
expect(result.success?).to eq(true)
|
7989
|
+
expect(result.transaction.shipping_tax_amount).to eq("0.40")
|
7990
|
+
expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
7991
|
+
end
|
7992
|
+
end
|
7854
7993
|
end
|
@@ -399,7 +399,7 @@ describe Braintree::Configuration do
|
|
399
399
|
|
400
400
|
it "is qa.braintreegateway.com for qa" do
|
401
401
|
Braintree::Configuration.environment = :qa
|
402
|
-
expect(Braintree::Configuration.instantiate.server).to eq("gateway.
|
402
|
+
expect(Braintree::Configuration.instantiate.server).to eq("gateway.qa2.braintreepayments.com")
|
403
403
|
end
|
404
404
|
|
405
405
|
it "can by changed by configuring the production endpoint" do
|
@@ -34,6 +34,7 @@ describe Braintree::CreditCard do
|
|
34
34
|
:country_name,
|
35
35
|
:extended_address,
|
36
36
|
:first_name,
|
37
|
+
{:international_phone=>[:country_code, :national_number]},
|
37
38
|
:last_name,
|
38
39
|
:locality,
|
39
40
|
:phone_number,
|
@@ -81,6 +82,7 @@ describe Braintree::CreditCard do
|
|
81
82
|
:country_name,
|
82
83
|
:extended_address,
|
83
84
|
:first_name,
|
85
|
+
{:international_phone=>[:country_code, :national_number]},
|
84
86
|
:last_name,
|
85
87
|
:locality,
|
86
88
|
:phone_number,
|
@@ -6,6 +6,8 @@ describe Braintree::CreditCardVerification do
|
|
6
6
|
verification = Braintree::CreditCardVerification._new(
|
7
7
|
:status => "verified",
|
8
8
|
:amount => "12.45",
|
9
|
+
:ani_first_name_response_code => "I",
|
10
|
+
:ani_last_name_response_code => "I",
|
9
11
|
:currency_iso_code => "USD",
|
10
12
|
:avs_error_response_code => "I",
|
11
13
|
:avs_postal_code_response_code => "I",
|
@@ -17,8 +19,7 @@ describe Braintree::CreditCardVerification do
|
|
17
19
|
:network_response_code => "05",
|
18
20
|
:network_response_text => "Do not Honor",
|
19
21
|
)
|
20
|
-
|
21
|
-
expect(verification.inspect).to eq(%(#<Braintree::CreditCardVerification status: "verified", processor_response_code: "2000", processor_response_text: "Do Not Honor", amount: "12.45", currency_iso_code: "USD", cvv_response_code: "I", avs_error_response_code: "I", avs_postal_code_response_code: "I", avs_street_address_response_code: "I", network_response_code: "05", network_response_text: "Do not Honor", merchant_account_id: "some_id", gateway_rejection_reason: nil, id: nil, credit_card: nil, billing: nil, created_at: nil>))
|
22
|
+
expect(verification.inspect).to eq(%(#<Braintree::CreditCardVerification amount: "12.45", ani_first_name_response_code: "I", ani_last_name_response_code: "I", avs_error_response_code: "I", avs_postal_code_response_code: "I", avs_street_address_response_code: "I", billing: nil, created_at: nil, credit_card: nil, currency_iso_code: "USD", cvv_response_code: "I", gateway_rejection_reason: nil, id: nil, merchant_account_id: "some_id", network_response_code: "05", network_response_text: "Do not Honor", processor_response_code: "2000", processor_response_text: "Do Not Honor", status: "verified">))
|
22
23
|
end
|
23
24
|
|
24
25
|
it "has a status" do
|
@@ -37,6 +38,16 @@ describe Braintree::CreditCardVerification do
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
it "accepts ani name reponse codes" do
|
42
|
+
verification = Braintree::CreditCardVerification._new(
|
43
|
+
:ani_first_name_response_code => "M",
|
44
|
+
:ani_last_name_response_code => "M",
|
45
|
+
)
|
46
|
+
|
47
|
+
expect(verification.ani_first_name_response_code).to eq("M")
|
48
|
+
expect(verification.ani_last_name_response_code).to eq("M")
|
49
|
+
end
|
50
|
+
|
40
51
|
it "accepts amount as either a String or BigDecimal" do
|
41
52
|
expect(Braintree::CreditCardVerification._new(:amount => "12.34").amount).to eq(BigDecimal("12.34"))
|
42
53
|
expect(Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount).to eq(BigDecimal("12.34"))
|