braintree 3.1.0 → 3.2.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.rb +2 -0
- data/lib/braintree/credit_card_gateway.rb +1 -1
- data/lib/braintree/error_codes.rb +5 -0
- data/lib/braintree/payment_method_gateway.rb +1 -1
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/transaction.rb +8 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction_gateway.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/spec/integration/braintree/customer_spec.rb +167 -0
- data/spec/integration/braintree/payment_method_spec.rb +177 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +8 -4
- data/spec/integration/braintree/transaction_spec.rb +194 -23
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +12 -6
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/braintree/credit_card_spec.rb +2 -2
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/resource_collection_spec.rb +29 -0
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d503215e210019aebf40c5b4f0d42f8e98721a728016930efedc008c138ccc
|
4
|
+
data.tar.gz: 688dca23d5029e44cdb81915b2935bdf93d1b3b68f0e44703b46856d4a1abf6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a3a1935223a681e1b7935ef2e81bbe68448ebac245e3fe460892c423098c0db6c9cc9d05d25e11539fe392fdc34cef60e8a41e18a1ed1e95191729cf5aa624c
|
7
|
+
data.tar.gz: bb1137c11f4ab8e12fba995e6fb547222ceb99f13231b393a8f631b487f11d74661c6d461383614eccdbce9acbbd8d91890bf8bd3c759b8579e0ecbbcccc24ce
|
data/lib/braintree.rb
CHANGED
@@ -141,6 +141,8 @@ require "braintree/transaction/status_details"
|
|
141
141
|
require "braintree/transaction/venmo_account_details"
|
142
142
|
require "braintree/transaction/visa_checkout_card_details"
|
143
143
|
require "braintree/transaction/samsung_pay_card_details"
|
144
|
+
require "braintree/transaction/installment"
|
145
|
+
require "braintree/transaction/installment/adjustment"
|
144
146
|
require "braintree/unknown_payment_method"
|
145
147
|
require "braintree/disbursement"
|
146
148
|
require "braintree/dispute_search"
|
@@ -79,7 +79,7 @@ module Braintree
|
|
79
79
|
|
80
80
|
def self._signature(type) # :nodoc:
|
81
81
|
billing_address_params = AddressGateway._shared_signature
|
82
|
-
options = [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]
|
82
|
+
options = [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type,:verification_currency_iso_code]
|
83
83
|
signature = [
|
84
84
|
:billing_address_id, :cardholder_name, :cvv, :expiration_date, :expiration_month,
|
85
85
|
:expiration_year, :number, :token, :venmo_sdk_payment_method_code, :device_data,
|
@@ -68,6 +68,7 @@ module Braintree
|
|
68
68
|
CardholderNameIsTooLong = "81723"
|
69
69
|
CreditCardTypeIsNotAccepted = "81703"
|
70
70
|
CreditCardTypeIsNotAcceptedBySubscriptionMerchantAccount = "81718"
|
71
|
+
CurrencyCodeNotSupportedByMerchantAccount = "91760"
|
71
72
|
CustomerIdIsInvalid = "91705"
|
72
73
|
CustomerIdIsRequired = "91704"
|
73
74
|
CvvIsInvalid = "81707"
|
@@ -301,6 +302,7 @@ module Braintree
|
|
301
302
|
CannotUpdateTransactionDetailsNotSubmittedForSettlement = "915129"
|
302
303
|
ChannelIsTooLong = "91550"
|
303
304
|
CreditCardIsRequired = "91508"
|
305
|
+
CurrencyCodeNotSupportedByMerchantAccount = "915214"
|
304
306
|
CustomFieldIsInvalid = "91526"
|
305
307
|
CustomFieldIsTooLong = "81527"
|
306
308
|
CustomerDefaultPaymentMethodCardTypeIsNotAccepted = "81509"
|
@@ -354,6 +356,7 @@ module Braintree
|
|
354
356
|
RefundAmountIsTooLarge = "91521"
|
355
357
|
RefundAuthHardDeclined = "915200"
|
356
358
|
RefundAuthSoftDeclined = "915201"
|
359
|
+
ScaExemptionInvalid = "915213"
|
357
360
|
ServiceFeeAmountCannotBeNegative = "91554"
|
358
361
|
ServiceFeeAmountFormatIsInvalid = "91555"
|
359
362
|
ServiceFeeAmountIsTooLarge = "91556"
|
@@ -507,6 +510,7 @@ module Braintree
|
|
507
510
|
end
|
508
511
|
|
509
512
|
module ExternalVault
|
513
|
+
# NEXT_MAJOR_VERSION remove this validation error as it is no longer returned by the gateway
|
510
514
|
CardTypeIsInvalid = "915178"
|
511
515
|
PreviousNetworkTransactionIdIsInvalid = "915179"
|
512
516
|
StatusIsInvalid = "915175"
|
@@ -775,6 +779,7 @@ module Braintree
|
|
775
779
|
end
|
776
780
|
|
777
781
|
module RiskData
|
782
|
+
# NEXT_MAJOR_VERSION Remove CustomerBrowserIsTooLong (this validation is no longer applied)
|
778
783
|
CustomerBrowserIsTooLong = "94701"
|
779
784
|
CustomerDeviceIdIsTooLong = "94702"
|
780
785
|
CustomerLocationZipInvalidCharacters = "94703"
|
@@ -19,7 +19,6 @@ module Braintree
|
|
19
19
|
|
20
20
|
def _do_create(path, params=nil) # :nodoc:
|
21
21
|
response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
|
22
|
-
|
23
22
|
if response[:api_error_response]
|
24
23
|
ErrorResult.new(@gateway, response[:api_error_response])
|
25
24
|
elsif response
|
@@ -152,6 +151,7 @@ module Braintree
|
|
152
151
|
:make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session,
|
153
152
|
:verification_amount, :us_bank_account_verification_method,
|
154
153
|
:verification_account_type,
|
154
|
+
:verification_currency_iso_code,
|
155
155
|
:paypal => [
|
156
156
|
:payee_email,
|
157
157
|
:order_id,
|
@@ -22,9 +22,14 @@ module Braintree
|
|
22
22
|
@ids.empty?
|
23
23
|
end
|
24
24
|
|
25
|
-
# Returns the first
|
26
|
-
def first
|
27
|
-
@
|
25
|
+
# Returns the first or the first N items in the collection or nil if the collection is empty
|
26
|
+
def first(amount = 1)
|
27
|
+
return nil if @ids.empty?
|
28
|
+
return @paging_block.call([@ids.first]).first if amount == 1
|
29
|
+
|
30
|
+
@ids.first(amount).each_slice(@page_size).flat_map do |page_of_ids|
|
31
|
+
@paging_block.call(page_of_ids)
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
35
|
# Only the maximum size of a resource collection can be determined since the data on the server can change while
|
@@ -121,6 +121,8 @@ module Braintree
|
|
121
121
|
attr_reader :google_pay_details
|
122
122
|
attr_reader :graphql_id
|
123
123
|
attr_reader :id
|
124
|
+
attr_reader :installment_count
|
125
|
+
attr_reader :installments
|
124
126
|
attr_reader :local_payment_details
|
125
127
|
attr_reader :merchant_account_id
|
126
128
|
attr_reader :network_response_code # Response code from the card network
|
@@ -143,9 +145,11 @@ module Braintree
|
|
143
145
|
attr_reader :recurring
|
144
146
|
attr_reader :refund_ids
|
145
147
|
attr_reader :refunded_transaction_id
|
148
|
+
attr_reader :refunded_installments
|
146
149
|
attr_reader :retrieval_reference_number
|
147
150
|
attr_reader :risk_data
|
148
151
|
attr_reader :samsung_pay_card_details
|
152
|
+
attr_reader :sca_exemption_requested
|
149
153
|
attr_reader :service_fee_amount
|
150
154
|
attr_reader :settlement_batch_id
|
151
155
|
attr_reader :shipping_amount
|
@@ -305,7 +309,11 @@ module Braintree
|
|
305
309
|
@us_bank_account_details = UsBankAccountDetails.new(attributes[:us_bank_account]) if attributes[:us_bank_account]
|
306
310
|
@visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])
|
307
311
|
@samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
|
312
|
+
@sca_exemption_requested = attributes[:sca_exemption_requested]
|
308
313
|
authorization_adjustments.map! { |attrs| AuthorizationAdjustment._new(attrs) } if authorization_adjustments
|
314
|
+
|
315
|
+
installments.map! { |attrs| Installment.new(attrs) } if installments
|
316
|
+
refunded_installments.map! { |attrs| Installment.new(attrs) } if refunded_installments
|
309
317
|
end
|
310
318
|
|
311
319
|
def inspect # :nodoc:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class Installment
|
4
|
+
include BaseModule
|
5
|
+
|
6
|
+
attr_reader :id
|
7
|
+
attr_reader :amount
|
8
|
+
attr_reader :projected_disbursement_date
|
9
|
+
attr_reader :actual_disbursement_date
|
10
|
+
attr_reader :adjustments
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
14
|
+
@amount = Util.to_big_decimal(amount)
|
15
|
+
adjustments.map! { |attrs| Adjustment.new(attrs) } if adjustments
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
attrs = [:id, :amount, :projected_disbursement_date, :actual_disbursement_date, :adjustments]
|
20
|
+
formatted_attrs = attrs.map do |attr|
|
21
|
+
"#{attr}: #{send(attr).inspect}"
|
22
|
+
end
|
23
|
+
|
24
|
+
"#<#{formatted_attrs.join(", ")}>"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class Installment
|
4
|
+
class Adjustment
|
5
|
+
include BaseModule
|
6
|
+
|
7
|
+
module Kind
|
8
|
+
Refund = "REFUND"
|
9
|
+
Dispute = "DISPUTE"
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :amount
|
13
|
+
attr_reader :kind
|
14
|
+
attr_reader :projected_disbursement_date
|
15
|
+
attr_reader :actual_disbursement_date
|
16
|
+
|
17
|
+
def initialize(attributes)
|
18
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
19
|
+
@amount = Util.to_big_decimal(amount)
|
20
|
+
end
|
21
|
+
|
22
|
+
def inspect
|
23
|
+
attrs = [:amount, :kind, :projected_disbursement_date, :actual_disbursement_date]
|
24
|
+
formatted_attrs = attrs.map do |attr|
|
25
|
+
"#{attr}: #{send(attr).inspect}"
|
26
|
+
end
|
27
|
+
|
28
|
+
"#<#{formatted_attrs.join(", ")}>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -180,6 +180,7 @@ module Braintree
|
|
180
180
|
:shared_shipping_address_id, :shipping_address_id, :shipping_amount,
|
181
181
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,
|
182
182
|
:three_d_secure_token, :transaction_source, :type, :venmo_sdk_payment_method_code,
|
183
|
+
:sca_exemption, :currency_iso_code,
|
183
184
|
{:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
|
184
185
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
185
186
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number]},
|
@@ -245,7 +246,8 @@ module Braintree
|
|
245
246
|
]},
|
246
247
|
]},
|
247
248
|
{:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
|
248
|
-
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
|
249
|
+
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
|
250
|
+
{:installments => [:count]},
|
249
251
|
]
|
250
252
|
end
|
251
253
|
|
data/lib/braintree/version.rb
CHANGED
@@ -257,6 +257,92 @@ describe Braintree::Customer do
|
|
257
257
|
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
258
258
|
end
|
259
259
|
|
260
|
+
it "can create a customer and a payment method at the same time after validating verification_currency_iso_code" do
|
261
|
+
result = Braintree::Customer.create(
|
262
|
+
:first_name => "Mike",
|
263
|
+
:last_name => "Jones",
|
264
|
+
:credit_card => {
|
265
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
266
|
+
:expiration_date => "05/2010",
|
267
|
+
:cvv => "100",
|
268
|
+
:options => {
|
269
|
+
:verify_card => true,
|
270
|
+
:verification_currency_iso_code => "USD"
|
271
|
+
}
|
272
|
+
}
|
273
|
+
)
|
274
|
+
|
275
|
+
result.success?.should == true
|
276
|
+
result.customer.first_name.should == "Mike"
|
277
|
+
result.customer.last_name.should == "Jones"
|
278
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
279
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
280
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
281
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
282
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
283
|
+
end
|
284
|
+
|
285
|
+
it "errors when verification_currency_iso_code is not supported by merchant account" do
|
286
|
+
result = Braintree::Customer.create(
|
287
|
+
:first_name => "Mike",
|
288
|
+
:last_name => "Jones",
|
289
|
+
:credit_card => {
|
290
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
291
|
+
:expiration_date => "05/2010",
|
292
|
+
:cvv => "100",
|
293
|
+
:options => {
|
294
|
+
:verify_card => true,
|
295
|
+
:verification_currency_iso_code => "GBP"
|
296
|
+
}
|
297
|
+
}
|
298
|
+
)
|
299
|
+
expect(result).to_not be_success
|
300
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
301
|
+
end
|
302
|
+
|
303
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and creates customer" do
|
304
|
+
result = Braintree::Customer.create(
|
305
|
+
:first_name => "Mike",
|
306
|
+
:last_name => "Jones",
|
307
|
+
:credit_card => {
|
308
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
309
|
+
:expiration_date => "05/2010",
|
310
|
+
:options => {
|
311
|
+
:verify_card => true,
|
312
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
313
|
+
:verification_currency_iso_code => "USD"
|
314
|
+
}
|
315
|
+
}
|
316
|
+
)
|
317
|
+
result.success?.should == true
|
318
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
319
|
+
result.customer.first_name.should == "Mike"
|
320
|
+
result.customer.last_name.should == "Jones"
|
321
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
322
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
323
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
324
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
325
|
+
end
|
326
|
+
|
327
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and returns error" do
|
328
|
+
result = Braintree::Customer.create(
|
329
|
+
:first_name => "Mike",
|
330
|
+
:last_name => "Jones",
|
331
|
+
:credit_card => {
|
332
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
333
|
+
:expiration_date => "05/2010",
|
334
|
+
:options => {
|
335
|
+
:verify_card => true,
|
336
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
337
|
+
:verification_currency_iso_code => "GBP"
|
338
|
+
}
|
339
|
+
}
|
340
|
+
)
|
341
|
+
expect(result).to_not be_success
|
342
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
343
|
+
end
|
344
|
+
|
345
|
+
|
260
346
|
it "can create a customer, payment method, and billing address at the same time" do
|
261
347
|
result = Braintree::Customer.create(
|
262
348
|
:first_name => "Mike",
|
@@ -1347,6 +1433,87 @@ describe Braintree::Customer do
|
|
1347
1433
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
1348
1434
|
end
|
1349
1435
|
|
1436
|
+
context "verification_currency_iso_code" do
|
1437
|
+
it "can update the customer after validating verification_currency_iso_code" do
|
1438
|
+
customer = Braintree::Customer.create!(
|
1439
|
+
:first_name => "Joe"
|
1440
|
+
)
|
1441
|
+
|
1442
|
+
result = Braintree::Customer.update(
|
1443
|
+
customer.id,
|
1444
|
+
:first_name => "New Joe",
|
1445
|
+
:credit_card => {
|
1446
|
+
:cardholder_name => "New Joe Cardholder",
|
1447
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1448
|
+
:expiration_date => "12/2009",
|
1449
|
+
:options => { :verify_card => true, :verification_currency_iso_code => "USD" }
|
1450
|
+
}
|
1451
|
+
)
|
1452
|
+
result.success?.should == true
|
1453
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
it "can update the customer after validating verification_currency_iso_code against the given verification_merchant_account_id" do
|
1457
|
+
customer = Braintree::Customer.create!(
|
1458
|
+
:first_name => "Joe"
|
1459
|
+
)
|
1460
|
+
|
1461
|
+
result = Braintree::Customer.update(
|
1462
|
+
customer.id,
|
1463
|
+
:first_name => "New Joe",
|
1464
|
+
:credit_card => {
|
1465
|
+
:cardholder_name => "New Joe Cardholder",
|
1466
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1467
|
+
:expiration_date => "12/2009",
|
1468
|
+
:options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD" }
|
1469
|
+
}
|
1470
|
+
)
|
1471
|
+
result.success?.should == true
|
1472
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1473
|
+
result.customer.credit_cards[0].verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1474
|
+
end
|
1475
|
+
|
1476
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in default merchant account" do
|
1477
|
+
customer = Braintree::Customer.create!(
|
1478
|
+
:first_name => "Joe"
|
1479
|
+
)
|
1480
|
+
|
1481
|
+
result = Braintree::Customer.update(
|
1482
|
+
customer.id,
|
1483
|
+
:first_name => "New Joe",
|
1484
|
+
:credit_card => {
|
1485
|
+
:cardholder_name => "New Joe Cardholder",
|
1486
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1487
|
+
:expiration_date => "12/2009",
|
1488
|
+
:options => { :verify_card => true, :verification_currency_iso_code => "GBP" }
|
1489
|
+
}
|
1490
|
+
)
|
1491
|
+
result.success?.should == false
|
1492
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1493
|
+
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in the given verification merchant account" do
|
1497
|
+
customer = Braintree::Customer.create!(
|
1498
|
+
:first_name => "Joe"
|
1499
|
+
)
|
1500
|
+
|
1501
|
+
result = Braintree::Customer.update(
|
1502
|
+
customer.id,
|
1503
|
+
:first_name => "New Joe",
|
1504
|
+
:credit_card => {
|
1505
|
+
:cardholder_name => "New Joe Cardholder",
|
1506
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1507
|
+
:expiration_date => "12/2009",
|
1508
|
+
:options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP" }
|
1509
|
+
}
|
1510
|
+
)
|
1511
|
+
result.success?.should == false
|
1512
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1513
|
+
|
1514
|
+
end
|
1515
|
+
end
|
1516
|
+
|
1350
1517
|
context "verification_account_type" do
|
1351
1518
|
it "updates the credit card with account_type credit" do
|
1352
1519
|
customer = Braintree::Customer.create!
|
@@ -849,6 +849,99 @@ describe Braintree::PaymentMethod do
|
|
849
849
|
payment_method.should be_a Braintree::UnknownPaymentMethod
|
850
850
|
end
|
851
851
|
end
|
852
|
+
|
853
|
+
context "verification_currency_iso_code" do
|
854
|
+
it "validates verification_currency_iso_code against currency configured in default merchant account" do
|
855
|
+
nonce = nonce_for_new_payment_method(
|
856
|
+
:credit_card => {
|
857
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
858
|
+
:expiration_month => "11",
|
859
|
+
:expiration_year => "2099",
|
860
|
+
}
|
861
|
+
)
|
862
|
+
customer = Braintree::Customer.create!
|
863
|
+
result = Braintree::PaymentMethod.create(
|
864
|
+
:payment_method_nonce => nonce,
|
865
|
+
:customer_id => customer.id,
|
866
|
+
:options => {
|
867
|
+
:verify_card => true,
|
868
|
+
:verification_currency_iso_code => "USD"
|
869
|
+
}
|
870
|
+
)
|
871
|
+
|
872
|
+
result.should be_success
|
873
|
+
result.payment_method.verification.currency_iso_code == "USD"
|
874
|
+
end
|
875
|
+
|
876
|
+
it "validates verification_currency_iso_code against currency configured in verification_merchant_account_id" do
|
877
|
+
nonce = nonce_for_new_payment_method(
|
878
|
+
:credit_card => {
|
879
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
880
|
+
:expiration_month => "11",
|
881
|
+
:expiration_year => "2099",
|
882
|
+
}
|
883
|
+
)
|
884
|
+
customer = Braintree::Customer.create!
|
885
|
+
result = Braintree::PaymentMethod.create(
|
886
|
+
:payment_method_nonce => nonce,
|
887
|
+
:customer_id => customer.id,
|
888
|
+
:options => {
|
889
|
+
:verify_card => true,
|
890
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
891
|
+
:verification_currency_iso_code => "USD"
|
892
|
+
}
|
893
|
+
)
|
894
|
+
|
895
|
+
result.should be_success
|
896
|
+
result.payment_method.verification.currency_iso_code == "USD"
|
897
|
+
result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
898
|
+
end
|
899
|
+
|
900
|
+
|
901
|
+
it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in default merchant account" do
|
902
|
+
nonce = nonce_for_new_payment_method(
|
903
|
+
:credit_card => {
|
904
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
905
|
+
:expiration_month => "11",
|
906
|
+
:expiration_year => "2099",
|
907
|
+
}
|
908
|
+
)
|
909
|
+
customer = Braintree::Customer.create!
|
910
|
+
result = Braintree::PaymentMethod.create(
|
911
|
+
:payment_method_nonce => nonce,
|
912
|
+
:customer_id => customer.id,
|
913
|
+
:options => {
|
914
|
+
:verify_card => true,
|
915
|
+
:verification_currency_iso_code => "GBP"
|
916
|
+
}
|
917
|
+
)
|
918
|
+
result.should_not be_success
|
919
|
+
result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
920
|
+
end
|
921
|
+
|
922
|
+
it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in verification_merchant_account_id" do
|
923
|
+
nonce = nonce_for_new_payment_method(
|
924
|
+
:credit_card => {
|
925
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
926
|
+
:expiration_month => "11",
|
927
|
+
:expiration_year => "2099",
|
928
|
+
}
|
929
|
+
)
|
930
|
+
customer = Braintree::Customer.create!
|
931
|
+
result = Braintree::PaymentMethod.create(
|
932
|
+
:payment_method_nonce => nonce,
|
933
|
+
:customer_id => customer.id,
|
934
|
+
:options => {
|
935
|
+
:verify_card => true,
|
936
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
937
|
+
:verification_currency_iso_code => "GBP"
|
938
|
+
}
|
939
|
+
)
|
940
|
+
|
941
|
+
result.should_not be_success
|
942
|
+
result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
943
|
+
end
|
944
|
+
end
|
852
945
|
end
|
853
946
|
|
854
947
|
describe "self.create!" do
|
@@ -1275,6 +1368,90 @@ describe Braintree::PaymentMethod do
|
|
1275
1368
|
updated_credit_card.expiration_date.should == "06/2013"
|
1276
1369
|
end
|
1277
1370
|
|
1371
|
+
context "verification_currency_iso_code" do
|
1372
|
+
it "validates verification_currency_iso_code and updates the credit card " do
|
1373
|
+
customer = Braintree::Customer.create!
|
1374
|
+
credit_card = Braintree::CreditCard.create!(
|
1375
|
+
:cardholder_name => "Original Holder",
|
1376
|
+
:customer_id => customer.id,
|
1377
|
+
:cvv => "123",
|
1378
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1379
|
+
:expiration_date => "05/2012"
|
1380
|
+
)
|
1381
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1382
|
+
:cardholder_name => "New Holder",
|
1383
|
+
:cvv => "456",
|
1384
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1385
|
+
:expiration_date => "06/2013",
|
1386
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "USD"}
|
1387
|
+
)
|
1388
|
+
update_result.success?.should == true
|
1389
|
+
update_result.payment_method.verification.currency_iso_code == "USD"
|
1390
|
+
end
|
1391
|
+
|
1392
|
+
it "validates verification_currency_iso_code against the given verification_merchant_account_id and updates the credit card " do
|
1393
|
+
customer = Braintree::Customer.create!
|
1394
|
+
credit_card = Braintree::CreditCard.create!(
|
1395
|
+
:cardholder_name => "Original Holder",
|
1396
|
+
:customer_id => customer.id,
|
1397
|
+
:cvv => "123",
|
1398
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1399
|
+
:expiration_date => "05/2012"
|
1400
|
+
)
|
1401
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1402
|
+
:cardholder_name => "New Holder",
|
1403
|
+
:cvv => "456",
|
1404
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1405
|
+
:expiration_date => "06/2013",
|
1406
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"}
|
1407
|
+
)
|
1408
|
+
update_result.success?.should == true
|
1409
|
+
update_result.payment_method.verification.currency_iso_code == "USD"
|
1410
|
+
update_result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1411
|
+
end
|
1412
|
+
|
1413
|
+
it "throws validation error when passing invalid verification_currency_iso_code" do
|
1414
|
+
customer = Braintree::Customer.create!
|
1415
|
+
credit_card = Braintree::CreditCard.create!(
|
1416
|
+
:cardholder_name => "Original Holder",
|
1417
|
+
:customer_id => customer.id,
|
1418
|
+
:cvv => "123",
|
1419
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1420
|
+
:expiration_date => "05/2012"
|
1421
|
+
)
|
1422
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1423
|
+
:cardholder_name => "New Holder",
|
1424
|
+
:cvv => "456",
|
1425
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1426
|
+
:expiration_date => "06/2013",
|
1427
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "GBP"}
|
1428
|
+
)
|
1429
|
+
expect(update_result).to_not be_success
|
1430
|
+
update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1431
|
+
end
|
1432
|
+
|
1433
|
+
it "throws validation error when passing invalid verification_currency_iso_code of the given verification merchant account id" do
|
1434
|
+
customer = Braintree::Customer.create!
|
1435
|
+
credit_card = Braintree::CreditCard.create!(
|
1436
|
+
:cardholder_name => "Original Holder",
|
1437
|
+
:customer_id => customer.id,
|
1438
|
+
:cvv => "123",
|
1439
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1440
|
+
:expiration_date => "05/2012"
|
1441
|
+
)
|
1442
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1443
|
+
:cardholder_name => "New Holder",
|
1444
|
+
:cvv => "456",
|
1445
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1446
|
+
:expiration_date => "06/2013",
|
1447
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"}
|
1448
|
+
)
|
1449
|
+
expect(update_result).to_not be_success
|
1450
|
+
update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1451
|
+
end
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
|
1278
1455
|
context "billing address" do
|
1279
1456
|
it "creates a new billing address by default" do
|
1280
1457
|
customer = Braintree::Customer.create!
|
@@ -13,7 +13,8 @@ describe Braintree::PaymentMethod do
|
|
13
13
|
context "plaid verified nonce" do
|
14
14
|
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
15
15
|
|
16
|
-
|
16
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
17
|
+
xit "succeeds" do
|
17
18
|
customer = Braintree::Customer.create.customer
|
18
19
|
result = Braintree::PaymentMethod.create(
|
19
20
|
:payment_method_nonce => nonce,
|
@@ -49,7 +50,8 @@ describe Braintree::PaymentMethod do
|
|
49
50
|
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
50
51
|
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
51
52
|
].each do |method|
|
52
|
-
|
53
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
54
|
+
xit "succeeds and verifies via #{method}" do
|
53
55
|
customer = Braintree::Customer.create.customer
|
54
56
|
result = Braintree::PaymentMethod.create(
|
55
57
|
:payment_method_nonce => nonce,
|
@@ -183,7 +185,8 @@ describe Braintree::PaymentMethod do
|
|
183
185
|
|
184
186
|
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
185
187
|
|
186
|
-
|
188
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
189
|
+
xit "succeeds and verifies via independent check" do
|
187
190
|
customer = Braintree::Customer.create.customer
|
188
191
|
result = Braintree::PaymentMethod.create(
|
189
192
|
:payment_method_nonce => nonce,
|
@@ -219,7 +222,8 @@ describe Braintree::PaymentMethod do
|
|
219
222
|
context "non plaid verified nonce" do
|
220
223
|
let(:nonce) { generate_non_plaid_us_bank_account_nonce }
|
221
224
|
|
222
|
-
|
225
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
226
|
+
xit "succeeds and verifies via independent check" do
|
223
227
|
customer = Braintree::Customer.create.customer
|
224
228
|
result = Braintree::PaymentMethod.create(
|
225
229
|
:payment_method_nonce => nonce,
|
@@ -159,7 +159,6 @@ describe Braintree::Transaction do
|
|
159
159
|
}
|
160
160
|
)
|
161
161
|
result.success?.should == false
|
162
|
-
result.errors.for(:transaction).for(:risk_data).on(:customer_browser).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerBrowserIsTooLong
|
163
162
|
result.errors.for(:transaction).for(:risk_data).on(:customer_device_id).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerDeviceIdIsTooLong
|
164
163
|
result.errors.for(:transaction).for(:risk_data).on(:customer_location_zip).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerLocationZipInvalidCharacters
|
165
164
|
result.errors.for(:transaction).for(:risk_data).on(:customer_tenure).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerTenureIsTooLong
|
@@ -182,6 +181,42 @@ describe Braintree::Transaction do
|
|
182
181
|
end
|
183
182
|
end
|
184
183
|
|
184
|
+
describe "sca_exemption" do
|
185
|
+
context "with a valid request" do
|
186
|
+
it "succeeds" do
|
187
|
+
requested_exemption = "low_value"
|
188
|
+
result = Braintree::Transaction.create(
|
189
|
+
:type => "sale",
|
190
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
191
|
+
:credit_card => {
|
192
|
+
:number => Braintree::Test::CreditCardNumbers::VisaCountryOfIssuanceIE,
|
193
|
+
:expiration_date => "05/2009"
|
194
|
+
},
|
195
|
+
:sca_exemption => requested_exemption,
|
196
|
+
)
|
197
|
+
expect(result).to be_success
|
198
|
+
expect(result.transaction.sca_exemption_requested).to eq(requested_exemption)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "with an invalid request" do
|
203
|
+
it "returns an error" do
|
204
|
+
result = Braintree::Transaction.create(
|
205
|
+
:type => "sale",
|
206
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
207
|
+
:credit_card => {
|
208
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
209
|
+
:expiration_date => "05/2009"
|
210
|
+
},
|
211
|
+
:sca_exemption => "invalid_sca_exemption_value",
|
212
|
+
)
|
213
|
+
sca_exemption_invalid = Braintree::ErrorCodes::Transaction::ScaExemptionInvalid
|
214
|
+
expect(result).not_to be_success
|
215
|
+
expect(result.errors.for(:transaction).map(&:code)).to eq([sca_exemption_invalid])
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
185
220
|
describe "industry data" do
|
186
221
|
context "for lodging" do
|
187
222
|
it "accepts valid industry data" do
|
@@ -4270,7 +4305,7 @@ describe Braintree::Transaction do
|
|
4270
4305
|
result.errors.for(:transaction).for(:external_vault).on(:status)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::StatusIsInvalid
|
4271
4306
|
end
|
4272
4307
|
|
4273
|
-
context "Visa/Mastercard/Discover" do
|
4308
|
+
context "Visa/Mastercard/Discover/AmEx" do
|
4274
4309
|
it "accepts status" do
|
4275
4310
|
result = Braintree::Transaction.create(
|
4276
4311
|
:type => "sale",
|
@@ -4322,12 +4357,12 @@ describe Braintree::Transaction do
|
|
4322
4357
|
end
|
4323
4358
|
end
|
4324
4359
|
|
4325
|
-
context "Non-(Visa/Mastercard/Discover) card types" do
|
4360
|
+
context "Non-(Visa/Mastercard/Discover/AmEx) card types" do
|
4326
4361
|
it "accepts status" do
|
4327
4362
|
result = Braintree::Transaction.create(
|
4328
4363
|
:type => "sale",
|
4329
4364
|
:credit_card => {
|
4330
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4365
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4331
4366
|
:expiration_date => "05/2009"
|
4332
4367
|
},
|
4333
4368
|
:external_vault => {
|
@@ -4343,7 +4378,7 @@ describe Braintree::Transaction do
|
|
4343
4378
|
result = Braintree::Transaction.create(
|
4344
4379
|
:type => "sale",
|
4345
4380
|
:credit_card => {
|
4346
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4381
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4347
4382
|
:expiration_date => "05/2009"
|
4348
4383
|
},
|
4349
4384
|
:external_vault => {
|
@@ -4355,25 +4390,7 @@ describe Braintree::Transaction do
|
|
4355
4390
|
result.success?.should == true
|
4356
4391
|
result.transaction.network_transaction_id.should be_nil
|
4357
4392
|
end
|
4358
|
-
|
4359
|
-
it "rejects previous_network_transaction_id" do
|
4360
|
-
result = Braintree::Transaction.create(
|
4361
|
-
:type => "sale",
|
4362
|
-
:credit_card => {
|
4363
|
-
:number => Braintree::Test::CreditCardNumbers::AmExes[0],
|
4364
|
-
:expiration_date => "05/2009"
|
4365
|
-
},
|
4366
|
-
:external_vault => {
|
4367
|
-
:status => Braintree::Transaction::ExternalVault::Status::Vaulted,
|
4368
|
-
:previous_network_transaction_id => "123456789012345",
|
4369
|
-
},
|
4370
|
-
:amount => "10.00",
|
4371
|
-
)
|
4372
|
-
result.success?.should == false
|
4373
|
-
result.errors.for(:transaction).for(:external_vault).on(:previous_network_transaction_id)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::CardTypeIsInvalid
|
4374
|
-
end
|
4375
4393
|
end
|
4376
|
-
|
4377
4394
|
end
|
4378
4395
|
|
4379
4396
|
context "account_type" do
|
@@ -4959,6 +4976,73 @@ describe Braintree::Transaction do
|
|
4959
4976
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
4960
4977
|
end
|
4961
4978
|
|
4979
|
+
it "validates currency_iso_code and creates transaction" do
|
4980
|
+
params = {
|
4981
|
+
:transaction => {
|
4982
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
4983
|
+
:currency_iso_code => "USD",
|
4984
|
+
:credit_card => {
|
4985
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4986
|
+
:expiration_date => "05/2009"
|
4987
|
+
}
|
4988
|
+
}
|
4989
|
+
}
|
4990
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
4991
|
+
result.success?.should == true
|
4992
|
+
result.transaction.currency_iso_code == "USD"
|
4993
|
+
end
|
4994
|
+
|
4995
|
+
it "validates currency_iso_code and returns error" do
|
4996
|
+
params = {
|
4997
|
+
:transaction => {
|
4998
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
4999
|
+
:currency_iso_code => "CAD",
|
5000
|
+
:credit_card => {
|
5001
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5002
|
+
:expiration_date => "05/2009"
|
5003
|
+
}
|
5004
|
+
}
|
5005
|
+
}
|
5006
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5007
|
+
result.success?.should == false
|
5008
|
+
result.errors.for(:transaction).on(:currency_iso_code)[0].code.should == Braintree::ErrorCodes::Transaction::CurrencyCodeNotSupportedByMerchantAccount
|
5009
|
+
end
|
5010
|
+
|
5011
|
+
it "validates currency_iso_code and creates transaction with specified merchant account" do
|
5012
|
+
params = {
|
5013
|
+
:transaction => {
|
5014
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5015
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
5016
|
+
:currency_iso_code => "USD",
|
5017
|
+
:credit_card => {
|
5018
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5019
|
+
:expiration_date => "05/2009"
|
5020
|
+
}
|
5021
|
+
}
|
5022
|
+
}
|
5023
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5024
|
+
result.success?.should == true
|
5025
|
+
result.transaction.currency_iso_code == "USD"
|
5026
|
+
result.transaction.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
5027
|
+
end
|
5028
|
+
|
5029
|
+
it "validates currency_iso_code and returns error with specified merchant account" do
|
5030
|
+
params = {
|
5031
|
+
:transaction => {
|
5032
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5033
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
5034
|
+
:currency_iso_code => "CAD",
|
5035
|
+
:credit_card => {
|
5036
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5037
|
+
:expiration_date => "05/2009"
|
5038
|
+
}
|
5039
|
+
}
|
5040
|
+
}
|
5041
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5042
|
+
result.success?.should == false
|
5043
|
+
result.errors.for(:transaction).on(:currency_iso_code)[0].code.should == Braintree::ErrorCodes::Transaction::CurrencyCodeNotSupportedByMerchantAccount
|
5044
|
+
end
|
5045
|
+
|
4962
5046
|
it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
|
4963
5047
|
with_advanced_fraud_integration_merchant do
|
4964
5048
|
result = Braintree::Transaction.sale(
|
@@ -6789,4 +6873,91 @@ describe Braintree::Transaction do
|
|
6789
6873
|
transaction.processed_with_network_token?.should == false
|
6790
6874
|
end
|
6791
6875
|
end
|
6876
|
+
|
6877
|
+
describe "installments" do
|
6878
|
+
it "creates a transaction with an installment count" do
|
6879
|
+
result = Braintree::Transaction.create(
|
6880
|
+
:type => "sale",
|
6881
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6882
|
+
:credit_card => {
|
6883
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6884
|
+
:expiration_date => "05/2009"
|
6885
|
+
},
|
6886
|
+
:amount => "100.01",
|
6887
|
+
:installments => {
|
6888
|
+
:count => 12,
|
6889
|
+
},
|
6890
|
+
)
|
6891
|
+
|
6892
|
+
expect(result.success?).to eq(true)
|
6893
|
+
expect(result.transaction.installment_count).to eq(12)
|
6894
|
+
end
|
6895
|
+
|
6896
|
+
it "creates a transaction with a installments during capture" do
|
6897
|
+
result = Braintree::Transaction.create(
|
6898
|
+
:type => "sale",
|
6899
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6900
|
+
:credit_card => {
|
6901
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6902
|
+
:expiration_date => "05/2009"
|
6903
|
+
},
|
6904
|
+
:amount => "100.01",
|
6905
|
+
:installments => {
|
6906
|
+
:count => 12,
|
6907
|
+
},
|
6908
|
+
:options => {
|
6909
|
+
:submit_for_settlement => true,
|
6910
|
+
},
|
6911
|
+
)
|
6912
|
+
|
6913
|
+
expect(result.success?).to eq(true)
|
6914
|
+
transaction = result.transaction
|
6915
|
+
expect(transaction.installment_count).to eq(12)
|
6916
|
+
|
6917
|
+
installments = transaction.installments
|
6918
|
+
expect(installments.map(&:id)).to match_array((1..12).map { |i| "#{transaction.id}_INST_#{i}" })
|
6919
|
+
expect(installments.map(&:amount)).to match_array([BigDecimal("8.33")] * 11 + [BigDecimal("8.38")])
|
6920
|
+
end
|
6921
|
+
|
6922
|
+
it "can refund a transaction with installments" do
|
6923
|
+
sale_result = Braintree::Transaction.create(
|
6924
|
+
:type => "sale",
|
6925
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6926
|
+
:credit_card => {
|
6927
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6928
|
+
:expiration_date => "05/2009"
|
6929
|
+
},
|
6930
|
+
:amount => "100.01",
|
6931
|
+
:installments => {
|
6932
|
+
:count => 12,
|
6933
|
+
},
|
6934
|
+
:options => {
|
6935
|
+
:submit_for_settlement => true,
|
6936
|
+
},
|
6937
|
+
)
|
6938
|
+
|
6939
|
+
expect(sale_result.success?).to eq(true)
|
6940
|
+
sale_transaction = sale_result.transaction
|
6941
|
+
|
6942
|
+
refund_result = Braintree::Transaction.refund(sale_transaction.id, "49.99")
|
6943
|
+
|
6944
|
+
expect(refund_result.success?).to eq(true)
|
6945
|
+
refund_transaction = refund_result.transaction
|
6946
|
+
installments = refund_transaction.refunded_installments
|
6947
|
+
|
6948
|
+
(1..11).each do |i|
|
6949
|
+
installment = installments.find { |installment| installment.id == "#{sale_transaction.id}_INST_#{i}" }
|
6950
|
+
|
6951
|
+
expect(installment.amount).to eq(BigDecimal("8.33"))
|
6952
|
+
expect(installment.adjustments.map(&:amount)).to match_array([BigDecimal("-4.16")])
|
6953
|
+
expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
|
6954
|
+
end
|
6955
|
+
|
6956
|
+
installment = installments.find { |installment| installment.id == "#{sale_transaction.id}_INST_12" }
|
6957
|
+
|
6958
|
+
expect(installment.amount).to eq(BigDecimal("8.38"))
|
6959
|
+
expect(installment.adjustments.map(&:amount)).to match_array([BigDecimal("-4.23")])
|
6960
|
+
expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
|
6961
|
+
end
|
6962
|
+
end
|
6792
6963
|
end
|
@@ -14,7 +14,8 @@ describe Braintree::Transaction do
|
|
14
14
|
let(:plaid_nonce) { generate_valid_plaid_us_bank_account_nonce }
|
15
15
|
|
16
16
|
context "nonce" do
|
17
|
-
|
17
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
18
|
+
xit "sale succeeds" do
|
18
19
|
result = Braintree::Transaction.create(
|
19
20
|
:type => "sale",
|
20
21
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -41,7 +42,8 @@ describe Braintree::Transaction do
|
|
41
42
|
end
|
42
43
|
|
43
44
|
context "token" do
|
44
|
-
|
45
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
46
|
+
xit "payment_method#create then sale succeeds" do
|
45
47
|
payment_method = Braintree::PaymentMethod.create(
|
46
48
|
:payment_method_nonce => plaid_nonce,
|
47
49
|
:customer_id => Braintree::Customer.create.customer.id,
|
@@ -84,7 +86,8 @@ describe Braintree::Transaction do
|
|
84
86
|
transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
|
85
87
|
end
|
86
88
|
|
87
|
-
|
89
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
90
|
+
xit "transaction#create store_in_vault then sale succeeds" do
|
88
91
|
result = Braintree::Transaction.create(
|
89
92
|
:type => "sale",
|
90
93
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -233,7 +236,8 @@ describe Braintree::Transaction do
|
|
233
236
|
let(:plaid_nonce) { generate_valid_plaid_us_bank_account_nonce }
|
234
237
|
|
235
238
|
context "nonce" do
|
236
|
-
|
239
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
240
|
+
xit "sale succeeds" do
|
237
241
|
result = Braintree::Transaction.create(
|
238
242
|
:type => "sale",
|
239
243
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -260,7 +264,8 @@ describe Braintree::Transaction do
|
|
260
264
|
end
|
261
265
|
|
262
266
|
context "token" do
|
263
|
-
|
267
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
268
|
+
xit "payment_method#create then sale succeeds" do
|
264
269
|
result = Braintree::PaymentMethod.create(
|
265
270
|
:payment_method_nonce => plaid_nonce,
|
266
271
|
:customer_id => Braintree::Customer.create.customer.id,
|
@@ -305,7 +310,8 @@ describe Braintree::Transaction do
|
|
305
310
|
transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
|
306
311
|
end
|
307
312
|
|
308
|
-
|
313
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
314
|
+
xit "transaction#create store_in_vault then sale succeeds" do
|
309
315
|
result = Braintree::Transaction.create(
|
310
316
|
:type => "sale",
|
311
317
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
data/spec/spec_helper.rb
CHANGED
@@ -39,6 +39,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
39
39
|
AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
|
40
40
|
AdyenMerchantAccountId = "adyen_ma"
|
41
41
|
HiperBRLMerchantAccountId = "hiper_brl"
|
42
|
+
CardProcessorBRLMerchantAccountId = "card_processor_brl"
|
42
43
|
|
43
44
|
TrialPlan = {
|
44
45
|
:description => "Plan for integration tests -- with trial",
|
@@ -24,7 +24,7 @@ describe Braintree::CreditCard do
|
|
24
24
|
:device_data,
|
25
25
|
:payment_method_nonce,
|
26
26
|
{:external_vault=>[:network_transaction_id]},
|
27
|
-
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
27
|
+
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
|
28
28
|
{:billing_address => [
|
29
29
|
:company,
|
30
30
|
:country_code_alpha2,
|
@@ -70,7 +70,7 @@ describe Braintree::CreditCard do
|
|
70
70
|
:device_data,
|
71
71
|
:payment_method_nonce,
|
72
72
|
{:external_vault=>[:network_transaction_id]},
|
73
|
-
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
73
|
+
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
|
74
74
|
{:billing_address => [
|
75
75
|
:company,
|
76
76
|
:country_code_alpha2,
|
@@ -100,7 +100,7 @@ describe Braintree::Customer do
|
|
100
100
|
:device_data,
|
101
101
|
:payment_method_nonce,
|
102
102
|
{:external_vault=>[:network_transaction_id]},
|
103
|
-
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
103
|
+
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
|
104
104
|
{:billing_address => [
|
105
105
|
:company,
|
106
106
|
:country_code_alpha2,
|
@@ -197,6 +197,7 @@ describe Braintree::Customer do
|
|
197
197
|
:venmo_sdk_session,
|
198
198
|
:fail_on_duplicate_payment_method,
|
199
199
|
:verification_account_type,
|
200
|
+
:verification_currency_iso_code,
|
200
201
|
:update_existing_token
|
201
202
|
]},
|
202
203
|
{:billing_address => [
|
@@ -18,6 +18,35 @@ describe "Braintree::ResourceCollection" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
describe "#first" do
|
22
|
+
it 'returns nil with no results' do
|
23
|
+
values = %w(a b c d e)
|
24
|
+
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [], :page_size => 2}) do |ids|
|
25
|
+
ids.map {|id| values[id] }
|
26
|
+
end
|
27
|
+
|
28
|
+
collection.first.should == nil
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with results' do
|
32
|
+
let(:collection) do
|
33
|
+
values = %w(a b c d e)
|
34
|
+
|
35
|
+
Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
|
36
|
+
ids.map {|id| values[id] }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns the first occourence' do
|
41
|
+
collection.first.should == 'a'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns the first N occourences' do
|
45
|
+
collection.first(4).should == ['a','b','c','d']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
21
50
|
describe "#ids" do
|
22
51
|
it "returns a list of the resource collection ids" do
|
23
52
|
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::Installment do
|
4
|
+
describe "inspect" do
|
5
|
+
it "assigns all fields" do
|
6
|
+
adjustment_attributes = {
|
7
|
+
:amount => "0.98",
|
8
|
+
:kind => "REFUND",
|
9
|
+
:projected_disbursement_date => "2020-01-03 01:02:03Z",
|
10
|
+
:actual_disbursement_date => "2020-01-04 01:02:03Z",
|
11
|
+
}
|
12
|
+
installment_attributes = {
|
13
|
+
:id => "abc123",
|
14
|
+
:amount => "1.23",
|
15
|
+
:projected_disbursement_date => "2020-01-01 01:02:03Z",
|
16
|
+
:actual_disbursement_date => "2020-01-02 01:02:03Z",
|
17
|
+
:adjustments => [adjustment_attributes],
|
18
|
+
}
|
19
|
+
|
20
|
+
installment = Braintree::Transaction::Installment.new(installment_attributes)
|
21
|
+
|
22
|
+
expect(installment.inspect).to eq('#<id: "abc123", amount: 0.123e1, projected_disbursement_date: "2020-01-01 01:02:03Z", actual_disbursement_date: "2020-01-02 01:02:03Z", adjustments: [#<amount: 0.98e0, kind: "REFUND", projected_disbursement_date: "2020-01-03 01:02:03Z", actual_disbursement_date: "2020-01-04 01:02:03Z">]>')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -157,6 +157,8 @@ files:
|
|
157
157
|
- lib/braintree/transaction/customer_details.rb
|
158
158
|
- lib/braintree/transaction/disbursement_details.rb
|
159
159
|
- lib/braintree/transaction/google_pay_details.rb
|
160
|
+
- lib/braintree/transaction/installment.rb
|
161
|
+
- lib/braintree/transaction/installment/adjustment.rb
|
160
162
|
- lib/braintree/transaction/local_payment_details.rb
|
161
163
|
- lib/braintree/transaction/paypal_details.rb
|
162
164
|
- lib/braintree/transaction/paypal_here_details.rb
|
@@ -279,6 +281,7 @@ files:
|
|
279
281
|
- spec/unit/braintree/transaction/credit_card_details_spec.rb
|
280
282
|
- spec/unit/braintree/transaction/customer_details_spec.rb
|
281
283
|
- spec/unit/braintree/transaction/deposit_details_spec.rb
|
284
|
+
- spec/unit/braintree/transaction/installment_spec.rb
|
282
285
|
- spec/unit/braintree/transaction/paypal_details_spec.rb
|
283
286
|
- spec/unit/braintree/transaction_search_spec.rb
|
284
287
|
- spec/unit/braintree/transaction_spec.rb
|