braintree 4.17.0 → 4.19.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/advanced_search.rb +1 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/http.rb +2 -4
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction.rb +10 -0
- data/lib/braintree/transaction_gateway.rb +21 -3
- data/lib/braintree/transaction_line_item.rb +11 -8
- data/lib/braintree/util.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +4 -3
- data/lib/braintree/webhook_testing_gateway.rb +78 -6
- data/lib/braintree/xml/parser.rb +2 -2
- data/lib/braintree.rb +1 -0
- data/spec/integration/braintree/address_spec.rb +3 -3
- data/spec/integration/braintree/advanced_search_spec.rb +3 -3
- data/spec/integration/braintree/client_api/client_token_spec.rb +0 -2
- data/spec/integration/braintree/client_api/spec_helper.rb +1 -1
- data/spec/integration/braintree/credit_card_spec.rb +11 -15
- data/spec/integration/braintree/credit_card_verification_spec.rb +2 -2
- data/spec/integration/braintree/customer_spec.rb +12 -12
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/dispute_spec.rb +1 -1
- data/spec/integration/braintree/document_upload_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +0 -2
- data/spec/integration/braintree/oauth_spec.rb +1 -1
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_spec.rb +12 -14
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +3 -3
- data/spec/integration/braintree/paypal_account_spec.rb +6 -6
- data/spec/integration/braintree/plan_spec.rb +0 -1
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +0 -2
- data/spec/integration/braintree/subscription_spec.rb +5 -6
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
- data/spec/integration/braintree/transaction_search_spec.rb +3 -7
- data/spec/integration/braintree/transaction_spec.rb +117 -49
- data/spec/unit/braintree/client_token_spec.rb +1 -1
- data/spec/unit/braintree/digest_spec.rb +0 -1
- data/spec/unit/braintree/error_result_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- data/spec/unit/braintree/paypal_account_spec.rb +1 -1
- data/spec/unit/braintree/transaction_gateway_spec.rb +3 -3
- data/spec/unit/braintree/transaction_spec.rb +2 -2
- data/spec/unit/braintree/webhook_notification_spec.rb +16 -0
- metadata +5 -2
@@ -2098,7 +2098,6 @@ describe Braintree::Transaction do
|
|
2098
2098
|
end
|
2099
2099
|
|
2100
2100
|
it "can create a transaction with a params nonce with PayPal account params" do
|
2101
|
-
customer = Braintree::Customer.create!
|
2102
2101
|
nonce = nonce_for_new_payment_method(
|
2103
2102
|
:paypal_account => {
|
2104
2103
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2132,8 +2131,9 @@ describe Braintree::Transaction do
|
|
2132
2131
|
meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
|
2133
2132
|
meta_checkout_card_details.container_id.should == "container123"
|
2134
2133
|
meta_checkout_card_details.customer_location.should == "US"
|
2135
|
-
|
2136
|
-
meta_checkout_card_details.
|
2134
|
+
next_year = Date.today().next_year().year.to_s
|
2135
|
+
meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
|
2136
|
+
meta_checkout_card_details.expiration_year.should == next_year
|
2137
2137
|
meta_checkout_card_details.expiration_month.should == "12"
|
2138
2138
|
meta_checkout_card_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2139
2139
|
meta_checkout_card_details.is_network_tokenized.should == false
|
@@ -2161,8 +2161,9 @@ describe Braintree::Transaction do
|
|
2161
2161
|
meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
2162
2162
|
meta_checkout_token_details.customer_location.should == "US"
|
2163
2163
|
meta_checkout_token_details.ecommerce_indicator.should == "07"
|
2164
|
-
|
2165
|
-
meta_checkout_token_details.
|
2164
|
+
next_year = Date.today().next_year().year.to_s
|
2165
|
+
meta_checkout_token_details.expiration_date.should == "12/".concat(next_year)
|
2166
|
+
meta_checkout_token_details.expiration_year.should == next_year
|
2166
2167
|
meta_checkout_token_details.expiration_month.should == "12"
|
2167
2168
|
meta_checkout_token_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2168
2169
|
meta_checkout_token_details.is_network_tokenized.should == true
|
@@ -2172,7 +2173,6 @@ describe Braintree::Transaction do
|
|
2172
2173
|
end
|
2173
2174
|
|
2174
2175
|
it "can create a transaction with a fake apple pay nonce" do
|
2175
|
-
customer = Braintree::Customer.create!
|
2176
2176
|
result = Braintree::Transaction.create(
|
2177
2177
|
:type => "sale",
|
2178
2178
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2201,7 +2201,6 @@ describe Braintree::Transaction do
|
|
2201
2201
|
end
|
2202
2202
|
|
2203
2203
|
it "can create a vaulted transaction with a fake apple pay nonce" do
|
2204
|
-
customer = Braintree::Customer.create!
|
2205
2204
|
result = Braintree::Transaction.create(
|
2206
2205
|
:type => "sale",
|
2207
2206
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2223,7 +2222,6 @@ describe Braintree::Transaction do
|
|
2223
2222
|
end
|
2224
2223
|
|
2225
2224
|
it "can create a transaction with a fake google pay proxy card nonce" do
|
2226
|
-
customer = Braintree::Customer.create!
|
2227
2225
|
result = Braintree::Transaction.create(
|
2228
2226
|
:type => "sale",
|
2229
2227
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2255,7 +2253,6 @@ describe Braintree::Transaction do
|
|
2255
2253
|
end
|
2256
2254
|
|
2257
2255
|
it "can create a vaulted transaction with a fake google pay proxy card nonce" do
|
2258
|
-
customer = Braintree::Customer.create!
|
2259
2256
|
result = Braintree::Transaction.create(
|
2260
2257
|
:type => "sale",
|
2261
2258
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2280,7 +2277,6 @@ describe Braintree::Transaction do
|
|
2280
2277
|
end
|
2281
2278
|
|
2282
2279
|
it "can create a transaction with a fake google pay network token nonce" do
|
2283
|
-
customer = Braintree::Customer.create!
|
2284
2280
|
result = Braintree::Transaction.create(
|
2285
2281
|
:type => "sale",
|
2286
2282
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2333,7 +2329,6 @@ describe Braintree::Transaction do
|
|
2333
2329
|
end
|
2334
2330
|
|
2335
2331
|
it "can create a transaction with an unknown nonce" do
|
2336
|
-
customer = Braintree::Customer.create!
|
2337
2332
|
result = Braintree::Transaction.create(
|
2338
2333
|
:type => "sale",
|
2339
2334
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -2362,7 +2357,6 @@ describe Braintree::Transaction do
|
|
2362
2357
|
end
|
2363
2358
|
|
2364
2359
|
it "can create a transaction with a payee id" do
|
2365
|
-
customer = Braintree::Customer.create!
|
2366
2360
|
nonce = nonce_for_new_payment_method(
|
2367
2361
|
:paypal_account => {
|
2368
2362
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2386,7 +2380,6 @@ describe Braintree::Transaction do
|
|
2386
2380
|
end
|
2387
2381
|
|
2388
2382
|
it "can create a transaction with a payee id in the options params" do
|
2389
|
-
customer = Braintree::Customer.create!
|
2390
2383
|
nonce = nonce_for_new_payment_method(
|
2391
2384
|
:paypal_account => {
|
2392
2385
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2411,7 +2404,6 @@ describe Braintree::Transaction do
|
|
2411
2404
|
end
|
2412
2405
|
|
2413
2406
|
it "can create a transaction with a payee id in options.paypal" do
|
2414
|
-
customer = Braintree::Customer.create!
|
2415
2407
|
nonce = nonce_for_new_payment_method(
|
2416
2408
|
:paypal_account => {
|
2417
2409
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2437,7 +2429,6 @@ describe Braintree::Transaction do
|
|
2437
2429
|
end
|
2438
2430
|
|
2439
2431
|
it "can create a transaction with a payee email" do
|
2440
|
-
customer = Braintree::Customer.create!
|
2441
2432
|
nonce = nonce_for_new_payment_method(
|
2442
2433
|
:paypal_account => {
|
2443
2434
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2461,7 +2452,6 @@ describe Braintree::Transaction do
|
|
2461
2452
|
end
|
2462
2453
|
|
2463
2454
|
it "can create a transaction with a payee email in the options params" do
|
2464
|
-
customer = Braintree::Customer.create!
|
2465
2455
|
nonce = nonce_for_new_payment_method(
|
2466
2456
|
:paypal_account => {
|
2467
2457
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2486,7 +2476,6 @@ describe Braintree::Transaction do
|
|
2486
2476
|
end
|
2487
2477
|
|
2488
2478
|
it "can create a transaction with a payee email in options.paypal" do
|
2489
|
-
customer = Braintree::Customer.create!
|
2490
2479
|
nonce = nonce_for_new_payment_method(
|
2491
2480
|
:paypal_account => {
|
2492
2481
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2512,7 +2501,6 @@ describe Braintree::Transaction do
|
|
2512
2501
|
end
|
2513
2502
|
|
2514
2503
|
it "can create a transaction with a paypal custom field" do
|
2515
|
-
customer = Braintree::Customer.create!
|
2516
2504
|
nonce = nonce_for_new_payment_method(
|
2517
2505
|
:paypal_account => {
|
2518
2506
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2538,7 +2526,6 @@ describe Braintree::Transaction do
|
|
2538
2526
|
end
|
2539
2527
|
|
2540
2528
|
it "can create a transaction with a paypal description" do
|
2541
|
-
customer = Braintree::Customer.create!
|
2542
2529
|
nonce = nonce_for_new_payment_method(
|
2543
2530
|
:paypal_account => {
|
2544
2531
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2564,7 +2551,6 @@ describe Braintree::Transaction do
|
|
2564
2551
|
end
|
2565
2552
|
|
2566
2553
|
it "can create a transaction with STC supplementary data" do
|
2567
|
-
customer = Braintree::Customer.create!
|
2568
2554
|
nonce = nonce_for_new_payment_method(
|
2569
2555
|
:paypal_account => {
|
2570
2556
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
@@ -2748,7 +2734,7 @@ describe Braintree::Transaction do
|
|
2748
2734
|
},
|
2749
2735
|
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2750
2736
|
:three_d_secure_pass_thru => {
|
2751
|
-
:eci_flag => "
|
2737
|
+
:eci_flag => "05",
|
2752
2738
|
:cavv => "some_cavv",
|
2753
2739
|
:xid => "some_xid",
|
2754
2740
|
:three_d_secure_version => "1.0.2",
|
@@ -2835,7 +2821,7 @@ describe Braintree::Transaction do
|
|
2835
2821
|
:expiration_date => "12/12",
|
2836
2822
|
},
|
2837
2823
|
:three_d_secure_pass_thru => {
|
2838
|
-
:eci_flag => "
|
2824
|
+
:eci_flag => "05",
|
2839
2825
|
:cavv => "some_cavv",
|
2840
2826
|
:xid => "some_xid",
|
2841
2827
|
:three_d_secure_version => "1.0.2",
|
@@ -2860,7 +2846,7 @@ describe Braintree::Transaction do
|
|
2860
2846
|
:expiration_date => "12/12",
|
2861
2847
|
},
|
2862
2848
|
:three_d_secure_pass_thru => {
|
2863
|
-
:eci_flag => "
|
2849
|
+
:eci_flag => "05",
|
2864
2850
|
:cavv => "some_cavv",
|
2865
2851
|
:xid => "some_xid",
|
2866
2852
|
:three_d_secure_version => "1.0.2",
|
@@ -2947,7 +2933,7 @@ describe Braintree::Transaction do
|
|
2947
2933
|
:expiration_date => "12/12",
|
2948
2934
|
},
|
2949
2935
|
:three_d_secure_pass_thru => {
|
2950
|
-
:eci_flag => "
|
2936
|
+
:eci_flag => "05",
|
2951
2937
|
:cavv => "some_cavv",
|
2952
2938
|
:xid => "some_xid",
|
2953
2939
|
:three_d_secure_version => "invalid",
|
@@ -2971,7 +2957,7 @@ describe Braintree::Transaction do
|
|
2971
2957
|
:expiration_date => "12/12",
|
2972
2958
|
},
|
2973
2959
|
:three_d_secure_pass_thru => {
|
2974
|
-
:eci_flag => "
|
2960
|
+
:eci_flag => "05",
|
2975
2961
|
:cavv => "some_cavv",
|
2976
2962
|
:xid => "some_xid",
|
2977
2963
|
:three_d_secure_version => "1.0.2",
|
@@ -2995,7 +2981,7 @@ describe Braintree::Transaction do
|
|
2995
2981
|
:expiration_date => "12/12",
|
2996
2982
|
},
|
2997
2983
|
:three_d_secure_pass_thru => {
|
2998
|
-
:eci_flag => "
|
2984
|
+
:eci_flag => "05",
|
2999
2985
|
:cavv => "some_cavv",
|
3000
2986
|
:xid => "some_xid",
|
3001
2987
|
:three_d_secure_version => "1.0.2",
|
@@ -3019,7 +3005,7 @@ describe Braintree::Transaction do
|
|
3019
3005
|
:expiration_date => "12/12",
|
3020
3006
|
},
|
3021
3007
|
:three_d_secure_pass_thru => {
|
3022
|
-
:eci_flag => "
|
3008
|
+
:eci_flag => "05",
|
3023
3009
|
:cavv => "some_cavv",
|
3024
3010
|
:xid => "some_xid",
|
3025
3011
|
:three_d_secure_version => "1.0.2",
|
@@ -3298,7 +3284,7 @@ describe Braintree::Transaction do
|
|
3298
3284
|
)
|
3299
3285
|
|
3300
3286
|
config = Braintree::Configuration.instantiate
|
3301
|
-
|
3287
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
3302
3288
|
transaction = Braintree::Transaction.find(transaction.id)
|
3303
3289
|
|
3304
3290
|
result = Braintree::Transaction.refund(
|
@@ -3388,7 +3374,7 @@ describe Braintree::Transaction do
|
|
3388
3374
|
},
|
3389
3375
|
)
|
3390
3376
|
config = Braintree::Configuration.instantiate
|
3391
|
-
|
3377
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
3392
3378
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2046.00")
|
3393
3379
|
expect(result.success?).to eq(false)
|
3394
3380
|
expect(result.transaction.id).to match(/^\w{6,}$/)
|
@@ -3409,7 +3395,7 @@ describe Braintree::Transaction do
|
|
3409
3395
|
},
|
3410
3396
|
)
|
3411
3397
|
config = Braintree::Configuration.instantiate
|
3412
|
-
|
3398
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
3413
3399
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2009.00")
|
3414
3400
|
expect(result.success?).to eq(false)
|
3415
3401
|
expect(result.transaction.id).to match(/^\w{6,}$/)
|
@@ -4605,6 +4591,84 @@ describe Braintree::Transaction do
|
|
4605
4591
|
expect(result.success?).to eq(false)
|
4606
4592
|
expect(result.errors.for(:transaction).on(:line_items)[0].code).to eq(Braintree::ErrorCodes::Transaction::TooManyLineItems)
|
4607
4593
|
end
|
4594
|
+
|
4595
|
+
context "UPC code and type" do
|
4596
|
+
let(:line_item) do
|
4597
|
+
{
|
4598
|
+
:quantity => "1",
|
4599
|
+
:name => "Name #1",
|
4600
|
+
:description => "Description #1",
|
4601
|
+
:kind => "debit",
|
4602
|
+
:unit_amount => "45.12",
|
4603
|
+
:unit_tax_amount => "1.23",
|
4604
|
+
:unit_of_measure => "gallon",
|
4605
|
+
:discount_amount => "1.02",
|
4606
|
+
:tax_amount => "4.50",
|
4607
|
+
:total_amount => "45.15",
|
4608
|
+
:product_code => "23434",
|
4609
|
+
:commodity_code => "9SAASSD8724",
|
4610
|
+
:url => "https://example.com/products/23434",
|
4611
|
+
:upc_code => "042100005264",
|
4612
|
+
:upc_type => "UPC-A",
|
4613
|
+
:image_url => "https://google.com/image.png",
|
4614
|
+
}
|
4615
|
+
end
|
4616
|
+
|
4617
|
+
it "accepts valid values" do
|
4618
|
+
result = Braintree::Transaction.create(
|
4619
|
+
:type => "sale",
|
4620
|
+
:amount => "45.15",
|
4621
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4622
|
+
:line_items => [line_item],
|
4623
|
+
)
|
4624
|
+
expect(result.success?).to eq(true)
|
4625
|
+
expect(result.transaction.line_items.length).to eq(1)
|
4626
|
+
line_item = result.transaction.line_items[0]
|
4627
|
+
expect(line_item.upc_code).to eq("042100005264")
|
4628
|
+
expect(line_item.upc_type).to eq("UPC-A")
|
4629
|
+
end
|
4630
|
+
|
4631
|
+
it "returns validation errors for invalid UPC code and type too long" do
|
4632
|
+
line_item[:upc_code] = "THISCODELONGERTHAN17CHARS"
|
4633
|
+
line_item[:upc_type] = "USB-C"
|
4634
|
+
result = Braintree::Transaction.create(
|
4635
|
+
:type => "sale",
|
4636
|
+
:amount => "45.15",
|
4637
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4638
|
+
:line_items => [line_item],
|
4639
|
+
)
|
4640
|
+
|
4641
|
+
expect(result.success?).to eq(false)
|
4642
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsTooLong)
|
4643
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsInvalid)
|
4644
|
+
end
|
4645
|
+
|
4646
|
+
it "returns UPC code missing error when code is not present" do
|
4647
|
+
line_item.delete(:upc_code)
|
4648
|
+
result = Braintree::Transaction.create(
|
4649
|
+
:type => "sale",
|
4650
|
+
:amount => "45.15",
|
4651
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4652
|
+
:line_items => [line_item],
|
4653
|
+
)
|
4654
|
+
|
4655
|
+
expect(result.success?).to eq(false)
|
4656
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsMissing)
|
4657
|
+
end
|
4658
|
+
|
4659
|
+
it "returns UPC type missing error when type is not present" do
|
4660
|
+
line_item.delete(:upc_type)
|
4661
|
+
result = Braintree::Transaction.create(
|
4662
|
+
:type => "sale",
|
4663
|
+
:amount => "45.15",
|
4664
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4665
|
+
:line_items => [line_item],
|
4666
|
+
)
|
4667
|
+
|
4668
|
+
expect(result.success?).to eq(false)
|
4669
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsMissing)
|
4670
|
+
end
|
4671
|
+
end
|
4608
4672
|
end
|
4609
4673
|
|
4610
4674
|
context "level 3 summary data" do
|
@@ -5820,7 +5884,7 @@ describe Braintree::Transaction do
|
|
5820
5884
|
end
|
5821
5885
|
|
5822
5886
|
context "Pinless debit transaction" do
|
5823
|
-
|
5887
|
+
it "succesfully submits for settlement" do
|
5824
5888
|
result = Braintree::Transaction.sale(
|
5825
5889
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5826
5890
|
:merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
|
@@ -5831,10 +5895,28 @@ describe Braintree::Transaction do
|
|
5831
5895
|
},
|
5832
5896
|
)
|
5833
5897
|
expect(result.success?).to be_truthy
|
5834
|
-
expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
5835
5898
|
expect(result.transaction.debit_network).not_to be_nil
|
5836
5899
|
end
|
5837
5900
|
end
|
5901
|
+
|
5902
|
+
context "Process debit as credit" do
|
5903
|
+
it "succesfully completed pinless eligible transaction in signature" do
|
5904
|
+
result = Braintree::Transaction.sale(
|
5905
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5906
|
+
:merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
|
5907
|
+
:currency_iso_code => "USD",
|
5908
|
+
:payment_method_nonce => Braintree::Test::Nonce::TransactablePinlessDebitVisa,
|
5909
|
+
:options => {
|
5910
|
+
:submit_for_settlement => true,
|
5911
|
+
:credit_card => {
|
5912
|
+
:process_debit_as_credit => true
|
5913
|
+
}
|
5914
|
+
},
|
5915
|
+
)
|
5916
|
+
expect(result.success?).to be_truthy
|
5917
|
+
expect(result.transaction.debit_network).to be_nil
|
5918
|
+
end
|
5919
|
+
end
|
5838
5920
|
end
|
5839
5921
|
|
5840
5922
|
describe "self.sale!" do
|
@@ -7158,7 +7240,7 @@ describe Braintree::Transaction do
|
|
7158
7240
|
)
|
7159
7241
|
|
7160
7242
|
config = Braintree::Configuration.instantiate
|
7161
|
-
|
7243
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
7162
7244
|
Braintree::Transaction.find(transaction.id)
|
7163
7245
|
end
|
7164
7246
|
|
@@ -7189,8 +7271,8 @@ describe Braintree::Transaction do
|
|
7189
7271
|
)
|
7190
7272
|
|
7191
7273
|
config = Braintree::Configuration.instantiate
|
7192
|
-
|
7193
|
-
|
7274
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
7275
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/escrow")
|
7194
7276
|
Braintree::Transaction.find(transaction.id)
|
7195
7277
|
end
|
7196
7278
|
|
@@ -7739,20 +7821,6 @@ describe Braintree::Transaction do
|
|
7739
7821
|
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
|
7740
7822
|
end
|
7741
7823
|
|
7742
|
-
it "returns failure, when transaction status is not authorized" do
|
7743
|
-
additional_params = {:options => {:submit_for_settlement => true}}
|
7744
|
-
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7745
|
-
expect(initial_transaction.success?).to eq(true)
|
7746
|
-
|
7747
|
-
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7748
|
-
initial_transaction.transaction.id, "85.50"
|
7749
|
-
)
|
7750
|
-
|
7751
|
-
expect(adjustment_transaction.success?).to eq(false)
|
7752
|
-
expect(adjustment_transaction.transaction.amount).to eq(BigDecimal("75.50"))
|
7753
|
-
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
|
7754
|
-
end
|
7755
|
-
|
7756
7824
|
it "returns failure, when transaction authorization type final or undefined" do
|
7757
7825
|
additional_params = {:transaction_source => "recurring"}
|
7758
7826
|
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
@@ -3,7 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
3
3
|
describe Braintree::Digest do
|
4
4
|
describe "self.hexdigest" do
|
5
5
|
it "returns the sha1 hmac of the input string (test case 6 from RFC 2202)" do
|
6
|
-
original_key = Braintree::Configuration.private_key
|
7
6
|
private_key = "\xaa" * 80
|
8
7
|
data = "Test Using Larger Than Block-Size Key - Hash Key First"
|
9
8
|
expect(Braintree::Digest.hexdigest(private_key, data)).to eq("aa4ae5e15272d00e95705637ce8a3b55ed402112")
|
@@ -5,7 +5,7 @@ describe Braintree::ErrorResult do
|
|
5
5
|
it "ignores data other than params, errors, and message" do
|
6
6
|
# so that we can add more data into the response in the future without breaking the client lib
|
7
7
|
expect do
|
8
|
-
|
8
|
+
Braintree::ErrorResult.new(
|
9
9
|
:gateway,
|
10
10
|
:params => "params",
|
11
11
|
:errors => {:errors => []},
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Package Tracking Unit Tests" do
|
4
|
+
describe "creates and validates requests" do
|
5
|
+
let(:gateway) do
|
6
|
+
config = Braintree::Configuration.new(
|
7
|
+
:merchant_id => "merchant_id",
|
8
|
+
:public_key => "public_key",
|
9
|
+
:private_key => "private_key",
|
10
|
+
)
|
11
|
+
Braintree::Gateway.new(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "creates transaction gateway package tracking request signature" do
|
15
|
+
expect(Braintree::TransactionGateway._package_tracking_request_signature).to match(
|
16
|
+
[
|
17
|
+
:carrier,
|
18
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
19
|
+
:notify_payer, :tracking_number,
|
20
|
+
],
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises an ArgumentError if transaction_id is an invalid format" do
|
25
|
+
expect do
|
26
|
+
Braintree::Transaction.package_tracking("invalid-transaction-id", {})
|
27
|
+
end.to raise_error(ArgumentError, "transaction_id is invalid")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises an exception if attributes contain an invalid key" do
|
31
|
+
expect do
|
32
|
+
Braintree::Transaction.package_tracking("txn123", {:invalid_key => "random", :carrier => "UPS", :tracking_number => "123123"})
|
33
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "handles response" do
|
38
|
+
it "parses the packages response correctly" do
|
39
|
+
transaction = Braintree::Transaction._new(
|
40
|
+
:gateway,
|
41
|
+
:shipments => [
|
42
|
+
{:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1"},
|
43
|
+
{:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2"}
|
44
|
+
],
|
45
|
+
)
|
46
|
+
expect(transaction.packages.size).to eq(2)
|
47
|
+
expect(transaction.packages[0].id).to eq("id1")
|
48
|
+
expect(transaction.packages[0].carrier).to eq("UPS")
|
49
|
+
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
50
|
+
expect(transaction.packages[0].paypal_tracking_id).to eq("pp_tracking_number_1")
|
51
|
+
|
52
|
+
expect(transaction.packages[1].id).to eq("id2")
|
53
|
+
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
54
|
+
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
55
|
+
expect(transaction.packages[1].paypal_tracking_id).to eq("pp_tracking_number_2")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "doesn't blow up if no shipments are present in the transaction response" do
|
59
|
+
transaction = Braintree::Transaction._new(
|
60
|
+
:gateway,
|
61
|
+
:shipments => [],
|
62
|
+
)
|
63
|
+
expect(transaction.packages.size).to eq(0)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "doesn't blow up if shipments tag is not present in the transaction response" do
|
67
|
+
transaction = Braintree::Transaction._new(
|
68
|
+
:gateway,
|
69
|
+
{},
|
70
|
+
)
|
71
|
+
expect(transaction.packages.size).to eq(0)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -4,7 +4,7 @@ describe Braintree::PayPalAccount do
|
|
4
4
|
describe "self.create" do
|
5
5
|
it "raises an exception if attributes contain an invalid key" do
|
6
6
|
expect do
|
7
|
-
|
7
|
+
Braintree::PayPalAccount.create(
|
8
8
|
:invalid_key => "bad stuff",
|
9
9
|
:options => {
|
10
10
|
:invalid_option => "bad option",
|
@@ -41,7 +41,7 @@ describe Braintree::TransactionGateway do
|
|
41
41
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
|
42
42
|
:transaction_source, :type, :venmo_sdk_payment_method_code, #Deprecated
|
43
43
|
:sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
|
44
|
-
{:line_items => [:
|
44
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
45
45
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
46
46
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
|
47
47
|
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
@@ -81,7 +81,7 @@ describe Braintree::TransactionGateway do
|
|
81
81
|
{:three_d_secure => [:required]},
|
82
82
|
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
|
83
83
|
{:venmo => [:profile_id]},
|
84
|
-
{:credit_card => [:account_type]},
|
84
|
+
{:credit_card => [:account_type, :process_debit_as_credit]},
|
85
85
|
]
|
86
86
|
},
|
87
87
|
{:external_vault => [
|
@@ -137,7 +137,7 @@ describe Braintree::TransactionGateway do
|
|
137
137
|
:discount_amount,
|
138
138
|
:shipping_amount,
|
139
139
|
:ships_from_postal_code,
|
140
|
-
:line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :
|
140
|
+
:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url],
|
141
141
|
])
|
142
142
|
end
|
143
143
|
end
|
@@ -200,8 +200,8 @@ describe Braintree::Transaction do
|
|
200
200
|
},
|
201
201
|
)
|
202
202
|
|
203
|
-
expect(transaction.three_d_secure_info.enrolled).to eq("Y")
|
204
203
|
expect(transaction.three_d_secure_info.status).to eq("authenticate_successful")
|
204
|
+
expect(transaction.three_d_secure_info.enrolled).to eq("Y")
|
205
205
|
expect(transaction.three_d_secure_info.liability_shifted).to eq(true)
|
206
206
|
expect(transaction.three_d_secure_info.liability_shift_possible).to eq(true)
|
207
207
|
end
|
@@ -258,7 +258,7 @@ describe Braintree::Transaction do
|
|
258
258
|
end
|
259
259
|
|
260
260
|
it "handles receiving custom as an empty string" do
|
261
|
-
|
261
|
+
Braintree::Transaction._new(
|
262
262
|
:gateway,
|
263
263
|
:custom => "\n ",
|
264
264
|
)
|
@@ -168,6 +168,22 @@ describe Braintree::WebhookNotification do
|
|
168
168
|
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
169
169
|
end
|
170
170
|
|
171
|
+
it "builds a sample notification for a dispute under_review webhook" do
|
172
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
173
|
+
Braintree::WebhookNotification::Kind::DisputeUnderReview,
|
174
|
+
dispute_id,
|
175
|
+
)
|
176
|
+
|
177
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
178
|
+
|
179
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeUnderReview)
|
180
|
+
|
181
|
+
dispute = notification.dispute
|
182
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::UnderReview)
|
183
|
+
expect(dispute.id).to eq(dispute_id)
|
184
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
185
|
+
end
|
186
|
+
|
171
187
|
it "builds a sample notification for a dispute won webhook" do
|
172
188
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
173
189
|
Braintree::WebhookNotification::Kind::DisputeWon,
|
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: 4.
|
4
|
+
version: 4.19.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: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/braintree/transaction/local_payment_details.rb
|
182
182
|
- lib/braintree/transaction/meta_checkout_card_details.rb
|
183
183
|
- lib/braintree/transaction/meta_checkout_token_details.rb
|
184
|
+
- lib/braintree/transaction/package_details.rb
|
184
185
|
- lib/braintree/transaction/payment_receipt.rb
|
185
186
|
- lib/braintree/transaction/payment_receipt/card_present_data.rb
|
186
187
|
- lib/braintree/transaction/payment_receipt/merchant_address.rb
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- spec/integration/braintree/merchant_account_spec.rb
|
251
252
|
- spec/integration/braintree/merchant_spec.rb
|
252
253
|
- spec/integration/braintree/oauth_spec.rb
|
254
|
+
- spec/integration/braintree/package_tracking_spec.rb
|
253
255
|
- spec/integration/braintree/payment_method_nonce_spec.rb
|
254
256
|
- spec/integration/braintree/payment_method_spec.rb
|
255
257
|
- spec/integration/braintree/payment_method_us_bank_account_spec.rb
|
@@ -311,6 +313,7 @@ files:
|
|
311
313
|
- spec/unit/braintree/meta_checkout_token_details_spec.rb
|
312
314
|
- spec/unit/braintree/meta_checkout_token_spec.rb
|
313
315
|
- spec/unit/braintree/modification_spec.rb
|
316
|
+
- spec/unit/braintree/package_tracking_spec.rb
|
314
317
|
- spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb
|
315
318
|
- spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
|
316
319
|
- spec/unit/braintree/payment_method_nonce_details_spec.rb
|