braintree 4.12.0 → 4.13.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/apple_pay_card.rb +2 -0
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/transaction/apple_pay_details.rb +12 -10
- data/lib/braintree/transaction.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +17 -1
- data/lib/braintree/version.rb +1 -1
- data/spec/integration/braintree/payment_method_spec.rb +61 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -163
- data/spec/integration/braintree/transaction_spec.rb +385 -172
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -242
- data/spec/unit/braintree/apple_pay_card_spec.rb +9 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +2 -1
- data/spec/unit/braintree/transaction_spec.rb +11 -0
- metadata +3 -3
@@ -451,6 +451,235 @@ describe Braintree::Transaction do
|
|
451
451
|
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative]
|
452
452
|
result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative]
|
453
453
|
end
|
454
|
+
|
455
|
+
[Braintree::Test::CreditCardNumbers::Discover, Braintree::Test::CreditCardNumbers::Visa].each do |card_number|
|
456
|
+
it "accepts valid industry data for card : #{card_number} " do
|
457
|
+
result = Braintree::Transaction.create(
|
458
|
+
:type => "sale",
|
459
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
460
|
+
:amount => 1_00,
|
461
|
+
:credit_card => {
|
462
|
+
:number => card_number,
|
463
|
+
:expiration_date => "05/2029"
|
464
|
+
},
|
465
|
+
:options => {
|
466
|
+
:submit_for_settlement => true
|
467
|
+
},
|
468
|
+
:industry => {
|
469
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
470
|
+
:data => {
|
471
|
+
:passenger_first_name => "John",
|
472
|
+
:passenger_last_name => "Doe",
|
473
|
+
:passenger_middle_initial => "M",
|
474
|
+
:passenger_title => "Mr.",
|
475
|
+
:issued_date => Date.new(2018, 1, 1),
|
476
|
+
:travel_agency_name => "Expedia",
|
477
|
+
:travel_agency_code => "12345678",
|
478
|
+
:ticket_number => "ticket-number",
|
479
|
+
:issuing_carrier_code => "AA",
|
480
|
+
:customer_code => "customer-code",
|
481
|
+
:fare_amount => 70_00,
|
482
|
+
:fee_amount => 10_00,
|
483
|
+
:tax_amount => 20_00,
|
484
|
+
:ticket_issuer_address => "Tkt-issuer-adr",
|
485
|
+
:arrival_date => Date.new(2018, 1, 2),
|
486
|
+
:restricted_ticket => false,
|
487
|
+
:legs => [
|
488
|
+
{
|
489
|
+
:conjunction_ticket => "CJ0001",
|
490
|
+
:exchange_ticket => "ET0001",
|
491
|
+
:coupon_number => "1",
|
492
|
+
:service_class => "Y",
|
493
|
+
:carrier_code => "AA",
|
494
|
+
:fare_basis_code => "W",
|
495
|
+
:flight_number => "AA100",
|
496
|
+
:departure_date => Date.new(2018, 1, 2),
|
497
|
+
:departure_airport_code => "MDW",
|
498
|
+
:departure_time => "08:00",
|
499
|
+
:arrival_airport_code => "AUS",
|
500
|
+
:arrival_time => "10:00",
|
501
|
+
:stopover_permitted => false,
|
502
|
+
:fare_amount => 35_00,
|
503
|
+
:fee_amount => 5_00,
|
504
|
+
:tax_amount => 10_00,
|
505
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
506
|
+
}
|
507
|
+
]
|
508
|
+
}
|
509
|
+
},
|
510
|
+
)
|
511
|
+
result.success?.should be(true)
|
512
|
+
end
|
513
|
+
|
514
|
+
|
515
|
+
it "2 step should be processed with AID(Airline Industry data) in step 1" do
|
516
|
+
result = Braintree::Transaction.create(
|
517
|
+
:type => "sale",
|
518
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
519
|
+
:amount => 1_00,
|
520
|
+
:credit_card => {
|
521
|
+
:number => card_number,
|
522
|
+
:expiration_date => "05/2029"
|
523
|
+
},
|
524
|
+
:industry => {
|
525
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
526
|
+
:data => {
|
527
|
+
:passenger_first_name => "John",
|
528
|
+
:passenger_last_name => "Doe",
|
529
|
+
:passenger_middle_initial => "M",
|
530
|
+
:passenger_title => "Mr.",
|
531
|
+
:issued_date => Date.new(2020, 1, 1),
|
532
|
+
:travel_agency_name => "Expedia",
|
533
|
+
:travel_agency_code => "12345678",
|
534
|
+
:ticket_number => "ticket-number",
|
535
|
+
:issuing_carrier_code => "AA",
|
536
|
+
:customer_code => "customer-code",
|
537
|
+
:fare_amount => 70_00,
|
538
|
+
:fee_amount => 10_00,
|
539
|
+
:tax_amount => 20_00,
|
540
|
+
:ticket_issuer_address => "Tkt-issuer-adr",
|
541
|
+
:arrival_date => Date.new(2020, 1, 1),
|
542
|
+
:restricted_ticket => false,
|
543
|
+
:legs => [
|
544
|
+
{
|
545
|
+
:conjunction_ticket => "CJ0001",
|
546
|
+
:exchange_ticket => "ET0001",
|
547
|
+
:coupon_number => "1",
|
548
|
+
:service_class => "Y",
|
549
|
+
:carrier_code => "AA",
|
550
|
+
:fare_basis_code => "W",
|
551
|
+
:flight_number => "AA100",
|
552
|
+
:departure_date => Date.new(2018, 1, 2),
|
553
|
+
:departure_airport_code => "MDW",
|
554
|
+
:departure_time => "08:00",
|
555
|
+
:arrival_airport_code => "ABC",
|
556
|
+
:arrival_time => "10:00",
|
557
|
+
:stopover_permitted => false,
|
558
|
+
:fare_amount => 35_00,
|
559
|
+
:fee_amount => 5_00,
|
560
|
+
:tax_amount => 10_00,
|
561
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
562
|
+
}
|
563
|
+
]
|
564
|
+
}
|
565
|
+
},
|
566
|
+
)
|
567
|
+
result.success?.should be(true)
|
568
|
+
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
569
|
+
|
570
|
+
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
|
571
|
+
|
572
|
+
result.success?.should == true
|
573
|
+
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
574
|
+
end
|
575
|
+
|
576
|
+
it "2 step should be processed with AID in step 2" do
|
577
|
+
result = Braintree::Transaction.create(
|
578
|
+
:type => "sale",
|
579
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
580
|
+
:amount => 1_00,
|
581
|
+
:credit_card => {
|
582
|
+
:number => card_number,
|
583
|
+
:expiration_date => "05/2029",
|
584
|
+
},
|
585
|
+
)
|
586
|
+
|
587
|
+
result.success?.should be(true)
|
588
|
+
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
589
|
+
|
590
|
+
options = {:industry => {
|
591
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
592
|
+
:data => {
|
593
|
+
:passenger_first_name => "John",
|
594
|
+
:passenger_last_name => "Doe",
|
595
|
+
:passenger_middle_initial => "M",
|
596
|
+
:passenger_title => "Mr.",
|
597
|
+
:issued_date => Date.new(2018, 1, 1),
|
598
|
+
:travel_agency_name => "Expedia",
|
599
|
+
:travel_agency_code => "12345678",
|
600
|
+
:ticket_number => "ticket-number",
|
601
|
+
:issuing_carrier_code => "AA",
|
602
|
+
:customer_code => "customer-code",
|
603
|
+
:fare_amount => 70_00,
|
604
|
+
:fee_amount => 10_00,
|
605
|
+
:tax_amount => 20_00,
|
606
|
+
:ticket_issuer_address => "Tkt-issuer-adr",
|
607
|
+
:arrival_date => Date.new(2020, 1, 1),
|
608
|
+
:restricted_ticket => false,
|
609
|
+
:legs => [
|
610
|
+
{
|
611
|
+
:conjunction_ticket => "CJ0001",
|
612
|
+
:exchange_ticket => "ET0001",
|
613
|
+
:coupon_number => "1",
|
614
|
+
:service_class => "Y",
|
615
|
+
:carrier_code => "AA",
|
616
|
+
:fare_basis_code => "W",
|
617
|
+
:flight_number => "AA100",
|
618
|
+
:departure_date => Date.new(2018, 1, 2),
|
619
|
+
:departure_airport_code => "MDW",
|
620
|
+
:departure_time => "08:00",
|
621
|
+
:arrival_airport_code => "ABC",
|
622
|
+
:arrival_time => "10:00",
|
623
|
+
:stopover_permitted => false,
|
624
|
+
:fare_amount => 35_00,
|
625
|
+
:fee_amount => 5_00,
|
626
|
+
:tax_amount => 10_00,
|
627
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
628
|
+
}
|
629
|
+
]
|
630
|
+
}
|
631
|
+
}
|
632
|
+
}
|
633
|
+
|
634
|
+
result = Braintree::Transaction.submit_for_settlement(result.transaction.id, nil, options)
|
635
|
+
|
636
|
+
result.success?.should == true
|
637
|
+
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
638
|
+
end
|
639
|
+
|
640
|
+
it "should not be processed with AID if validations on industry data fails for card : #{card_number}" do
|
641
|
+
result = Braintree::Transaction.create(
|
642
|
+
:type => "sale",
|
643
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
644
|
+
:amount => 1_00,
|
645
|
+
:credit_card => {
|
646
|
+
:number => card_number,
|
647
|
+
:expiration_date => "05/2029"
|
648
|
+
},
|
649
|
+
:options => {
|
650
|
+
:submit_for_settlement => true
|
651
|
+
},
|
652
|
+
:industry => {
|
653
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
654
|
+
:data => {
|
655
|
+
:passenger_middle_initial => "CD",
|
656
|
+
:fare_amount => -1_23,
|
657
|
+
:issuing_carrier_code => "-AA",
|
658
|
+
:restricted_ticket => false,
|
659
|
+
:ticket_number => "A" * 30,
|
660
|
+
:legs => [
|
661
|
+
{
|
662
|
+
:conjunction_ticket => "C"*25,
|
663
|
+
:fare_amount => -1_23,
|
664
|
+
:carrier_code => ".AA",
|
665
|
+
}
|
666
|
+
]
|
667
|
+
}
|
668
|
+
},
|
669
|
+
)
|
670
|
+
result.success?.should be(false)
|
671
|
+
[
|
672
|
+
Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative,
|
673
|
+
Braintree::ErrorCodes::Transaction::Industry::TravelFlight::PassengerMiddleInitialIsTooLong,
|
674
|
+
Braintree::ErrorCodes::Transaction::Industry::TravelFlight::TicketNumberIsTooLong,
|
675
|
+
].should include(*result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort)
|
676
|
+
[
|
677
|
+
Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::CarrierCodeIsTooLong,
|
678
|
+
Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative,
|
679
|
+
Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::ConjunctionTicketIsTooLong,
|
680
|
+
].should include(*result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort)
|
681
|
+
end
|
682
|
+
end
|
454
683
|
end
|
455
684
|
end
|
456
685
|
|
@@ -1561,6 +1790,19 @@ describe Braintree::Transaction do
|
|
1561
1790
|
result.transaction.recurring.should == false
|
1562
1791
|
end
|
1563
1792
|
|
1793
|
+
it "marks a transactions as pre_auth" do
|
1794
|
+
result = Braintree::Transaction.create(
|
1795
|
+
:type => "sale",
|
1796
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1797
|
+
:credit_card => {
|
1798
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1799
|
+
:expiration_date => "12/26",
|
1800
|
+
},
|
1801
|
+
:transaction_source => "estimated",
|
1802
|
+
)
|
1803
|
+
result.success?.should == true
|
1804
|
+
end
|
1805
|
+
|
1564
1806
|
it "handles validation when transaction source invalid" do
|
1565
1807
|
result = Braintree::Transaction.create(
|
1566
1808
|
:type => "sale",
|
@@ -1655,6 +1897,31 @@ describe Braintree::Transaction do
|
|
1655
1897
|
end
|
1656
1898
|
end
|
1657
1899
|
|
1900
|
+
context "processing_overrides" do
|
1901
|
+
it "creates a successful transaction with options processing_overrides" do
|
1902
|
+
result = Braintree::Transaction.create(
|
1903
|
+
:type => "sale",
|
1904
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1905
|
+
:customer => {
|
1906
|
+
:last_name => "Doe"
|
1907
|
+
},
|
1908
|
+
:credit_card => {
|
1909
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1910
|
+
:expiration_date => "12/12",
|
1911
|
+
},
|
1912
|
+
:options => {
|
1913
|
+
:processing_overrides => {
|
1914
|
+
:customer_email => "RubySDK@example.com",
|
1915
|
+
:customer_first_name => "RubySDK_test_customer_first_name",
|
1916
|
+
:customer_last_name => "RubySDK_test customer_last_name",
|
1917
|
+
:customer_tax_identifier => "1.2.3.4.5.6"
|
1918
|
+
},
|
1919
|
+
},
|
1920
|
+
)
|
1921
|
+
expect(result.success?).to eq(true)
|
1922
|
+
end
|
1923
|
+
end
|
1924
|
+
|
1658
1925
|
context "service fees" do
|
1659
1926
|
it "allows specifying service fees" do
|
1660
1927
|
result = Braintree::Transaction.create(
|
@@ -2907,6 +3174,76 @@ describe Braintree::Transaction do
|
|
2907
3174
|
end
|
2908
3175
|
end
|
2909
3176
|
|
3177
|
+
[Braintree::Test::CreditCardNumbers::Discover, Braintree::Test::CreditCardNumbers::Visa].each do |card_number|
|
3178
|
+
it "successfully refunds a transaction with AID" do
|
3179
|
+
transaction = Braintree::Transaction.sale!(
|
3180
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
3181
|
+
:credit_card => {
|
3182
|
+
:number => card_number,
|
3183
|
+
:expiration_date => "05/2009"
|
3184
|
+
},
|
3185
|
+
:options => {
|
3186
|
+
:submit_for_settlement => true
|
3187
|
+
},
|
3188
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
3189
|
+
:industry => {
|
3190
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
3191
|
+
:data => {
|
3192
|
+
:passenger_first_name => "John",
|
3193
|
+
:passenger_last_name => "Doe",
|
3194
|
+
:passenger_middle_initial => "M",
|
3195
|
+
:passenger_title => "Mr.",
|
3196
|
+
:issued_date => Date.new(2018, 1, 1),
|
3197
|
+
:travel_agency_name => "Expedia",
|
3198
|
+
:travel_agency_code => "12345678",
|
3199
|
+
:ticket_number => "ticket-number",
|
3200
|
+
:issuing_carrier_code => "AA",
|
3201
|
+
:customer_code => "customer-code",
|
3202
|
+
:fare_amount => 70_00,
|
3203
|
+
:fee_amount => 10_00,
|
3204
|
+
:tax_amount => 20_00,
|
3205
|
+
:ticket_issuer_address => "Tkt-issuer-adr",
|
3206
|
+
:arrival_date => Date.new(2020, 1, 2),
|
3207
|
+
:restricted_ticket => false,
|
3208
|
+
:legs => [
|
3209
|
+
{
|
3210
|
+
:conjunction_ticket => "CJ0001",
|
3211
|
+
:exchange_ticket => "ET0001",
|
3212
|
+
:coupon_number => "1",
|
3213
|
+
:service_class => "Y",
|
3214
|
+
:carrier_code => "AA",
|
3215
|
+
:fare_basis_code => "W",
|
3216
|
+
:flight_number => "AA100",
|
3217
|
+
:departure_date => Date.new(2020, 1, 2),
|
3218
|
+
:departure_airport_code => "MDW",
|
3219
|
+
:departure_time => "08:00",
|
3220
|
+
:arrival_airport_code => "ABC",
|
3221
|
+
:arrival_time => "10:00",
|
3222
|
+
:stopover_permitted => false,
|
3223
|
+
:fare_amount => 35_00,
|
3224
|
+
:fee_amount => 5_00,
|
3225
|
+
:tax_amount => 10_00,
|
3226
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE",
|
3227
|
+
},
|
3228
|
+
]
|
3229
|
+
},
|
3230
|
+
},
|
3231
|
+
)
|
3232
|
+
|
3233
|
+
config = Braintree::Configuration.instantiate
|
3234
|
+
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
3235
|
+
transaction = Braintree::Transaction.find(transaction.id)
|
3236
|
+
|
3237
|
+
result = Braintree::Transaction.refund(
|
3238
|
+
transaction.id,
|
3239
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
3240
|
+
)
|
3241
|
+
|
3242
|
+
result.success?.should == true
|
3243
|
+
result.transaction.type.should == "credit"
|
3244
|
+
end
|
3245
|
+
end
|
3246
|
+
|
2910
3247
|
it "returns a successful result if successful" do
|
2911
3248
|
transaction = create_paypal_transaction_for_refund
|
2912
3249
|
|
@@ -5268,152 +5605,6 @@ describe Braintree::Transaction do
|
|
5268
5605
|
expect(result.errors.for(:transaction).for(:credit_card).map { |e| e.code }.sort).to eq [Braintree::ErrorCodes::CreditCard::NetworkTokenizationAttributeCryptogramIsRequired]
|
5269
5606
|
end
|
5270
5607
|
end
|
5271
|
-
|
5272
|
-
xit "Amex Pay with Points" do
|
5273
|
-
context "transaction creation" do
|
5274
|
-
it "succeeds when submit_for_settlement is true" do
|
5275
|
-
result = Braintree::Transaction.sale(
|
5276
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5277
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5278
|
-
:credit_card => {
|
5279
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5280
|
-
:expiration_date => "05/2009"
|
5281
|
-
},
|
5282
|
-
:options => {
|
5283
|
-
:submit_for_settlement => true,
|
5284
|
-
:amex_rewards => {
|
5285
|
-
:request_id => "ABC123",
|
5286
|
-
:points => "1000",
|
5287
|
-
:currency_amount => "10.00",
|
5288
|
-
:currency_iso_code => "USD"
|
5289
|
-
}
|
5290
|
-
},
|
5291
|
-
)
|
5292
|
-
result.success?.should == true
|
5293
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5294
|
-
end
|
5295
|
-
|
5296
|
-
it "succeeds even if the card is ineligible" do
|
5297
|
-
result = Braintree::Transaction.sale(
|
5298
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5299
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5300
|
-
:credit_card => {
|
5301
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard,
|
5302
|
-
:expiration_date => "05/2009"
|
5303
|
-
},
|
5304
|
-
:options => {
|
5305
|
-
:submit_for_settlement => true,
|
5306
|
-
:amex_rewards => {
|
5307
|
-
:request_id => "ABC123",
|
5308
|
-
:points => "1000",
|
5309
|
-
:currency_amount => "10.00",
|
5310
|
-
:currency_iso_code => "USD"
|
5311
|
-
}
|
5312
|
-
},
|
5313
|
-
)
|
5314
|
-
result.success?.should == true
|
5315
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5316
|
-
end
|
5317
|
-
|
5318
|
-
it "succeeds even if the card's balance is insufficient" do
|
5319
|
-
result = Braintree::Transaction.sale(
|
5320
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5321
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5322
|
-
:credit_card => {
|
5323
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::InsufficientPoints,
|
5324
|
-
:expiration_date => "05/2009"
|
5325
|
-
},
|
5326
|
-
:options => {
|
5327
|
-
:submit_for_settlement => true,
|
5328
|
-
:amex_rewards => {
|
5329
|
-
:request_id => "ABC123",
|
5330
|
-
:points => "1000",
|
5331
|
-
:currency_amount => "10.00",
|
5332
|
-
:currency_iso_code => "USD"
|
5333
|
-
}
|
5334
|
-
},
|
5335
|
-
)
|
5336
|
-
result.success?.should == true
|
5337
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5338
|
-
end
|
5339
|
-
end
|
5340
|
-
|
5341
|
-
context "submit for settlement" do
|
5342
|
-
it "succeeds" do
|
5343
|
-
result = Braintree::Transaction.sale(
|
5344
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5345
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5346
|
-
:credit_card => {
|
5347
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5348
|
-
:expiration_date => "05/2009"
|
5349
|
-
},
|
5350
|
-
:options => {
|
5351
|
-
:amex_rewards => {
|
5352
|
-
:request_id => "ABC123",
|
5353
|
-
:points => "1000",
|
5354
|
-
:currency_amount => "10.00",
|
5355
|
-
:currency_iso_code => "USD"
|
5356
|
-
}
|
5357
|
-
},
|
5358
|
-
)
|
5359
|
-
result.success?.should == true
|
5360
|
-
|
5361
|
-
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
|
5362
|
-
result.success?.should == true
|
5363
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5364
|
-
end
|
5365
|
-
|
5366
|
-
it "succeeds even if the card is ineligible" do
|
5367
|
-
result = Braintree::Transaction.sale(
|
5368
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5369
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5370
|
-
:credit_card => {
|
5371
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard,
|
5372
|
-
:expiration_date => "05/2009"
|
5373
|
-
},
|
5374
|
-
:options => {
|
5375
|
-
:amex_rewards => {
|
5376
|
-
:request_id => "ABC123",
|
5377
|
-
:points => "1000",
|
5378
|
-
:currency_amount => "10.00",
|
5379
|
-
:currency_iso_code => "USD"
|
5380
|
-
}
|
5381
|
-
},
|
5382
|
-
)
|
5383
|
-
result.success?.should == true
|
5384
|
-
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
5385
|
-
|
5386
|
-
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
|
5387
|
-
result.success?.should == true
|
5388
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5389
|
-
end
|
5390
|
-
|
5391
|
-
it "succeeds even if the card's balance is insufficient" do
|
5392
|
-
result = Braintree::Transaction.sale(
|
5393
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5394
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5395
|
-
:credit_card => {
|
5396
|
-
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard,
|
5397
|
-
:expiration_date => "05/2009"
|
5398
|
-
},
|
5399
|
-
:options => {
|
5400
|
-
:amex_rewards => {
|
5401
|
-
:request_id => "ABC123",
|
5402
|
-
:points => "1000",
|
5403
|
-
:currency_amount => "10.00",
|
5404
|
-
:currency_iso_code => "USD"
|
5405
|
-
}
|
5406
|
-
},
|
5407
|
-
)
|
5408
|
-
result.success?.should == true
|
5409
|
-
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
5410
|
-
|
5411
|
-
result = Braintree::Transaction.submit_for_settlement(result.transaction.id)
|
5412
|
-
result.success?.should == true
|
5413
|
-
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5414
|
-
end
|
5415
|
-
end
|
5416
|
-
end
|
5417
5608
|
end
|
5418
5609
|
|
5419
5610
|
describe "self.sale!" do
|
@@ -6973,6 +7164,7 @@ describe Braintree::Transaction do
|
|
6973
7164
|
:amount => Braintree::Test::TransactionAmounts::Decline,
|
6974
7165
|
:payment_method_token => "network_tokenized_credit_card",
|
6975
7166
|
)
|
7167
|
+
|
6976
7168
|
transaction = result.transaction
|
6977
7169
|
transaction.retried.should == true
|
6978
7170
|
end
|
@@ -7000,6 +7192,53 @@ describe Braintree::Transaction do
|
|
7000
7192
|
end
|
7001
7193
|
end
|
7002
7194
|
|
7195
|
+
describe "retried_transaction_id and retry_ids presence in transaction response" do
|
7196
|
+
context "when it creates a retried transaction" do
|
7197
|
+
it "has retry_ids in the first transaction" do
|
7198
|
+
result = Braintree::Transaction.sale(
|
7199
|
+
:amount => Braintree::Test::TransactionAmounts::Decline,
|
7200
|
+
:payment_method_token => "network_tokenized_credit_card",
|
7201
|
+
:merchant_account_id => "ma_transaction_multiple_retries",
|
7202
|
+
)
|
7203
|
+
|
7204
|
+
transaction = result.transaction
|
7205
|
+
transaction.retried_transaction_id.should == nil
|
7206
|
+
transaction.retry_ids.should_not == []
|
7207
|
+
transaction.retry_ids.count.should == 2
|
7208
|
+
|
7209
|
+
# verify retried_transaction_id is in the all retried transactions
|
7210
|
+
retry_transaction_1 = transaction.retry_ids[0]
|
7211
|
+
collection_1 = Braintree::Transaction.search do |search|
|
7212
|
+
search.id.is retry_transaction_1
|
7213
|
+
end
|
7214
|
+
collection_1.maximum_size.should == 1
|
7215
|
+
collection_1.first.retried_transaction_id.should_not == nil
|
7216
|
+
collection_1.first.retried_transaction_id.should == transaction.id
|
7217
|
+
|
7218
|
+
retry_transaction_2 = transaction.retry_ids[1]
|
7219
|
+
collection_2 = Braintree::Transaction.search do |search|
|
7220
|
+
search.id.is retry_transaction_2
|
7221
|
+
end
|
7222
|
+
collection_2.maximum_size.should == 1
|
7223
|
+
collection_2.first.retried_transaction_id.should_not == nil
|
7224
|
+
collection_2.first.retried_transaction_id.should == transaction.id
|
7225
|
+
end
|
7226
|
+
end
|
7227
|
+
|
7228
|
+
context "when it creates a non-retried transaction" do
|
7229
|
+
it "does not have retried_transaction_id and retry_ids in the transaction" do
|
7230
|
+
result = Braintree::Transaction.sale(
|
7231
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
7232
|
+
:payment_method_token => "network_tokenized_credit_card",
|
7233
|
+
)
|
7234
|
+
|
7235
|
+
transaction = result.transaction
|
7236
|
+
transaction.retried_transaction_id.should == nil
|
7237
|
+
transaction.retry_ids.should == []
|
7238
|
+
end
|
7239
|
+
end
|
7240
|
+
end
|
7241
|
+
|
7003
7242
|
describe "installments" do
|
7004
7243
|
it "creates a transaction with an installment count" do
|
7005
7244
|
result = Braintree::Transaction.create(
|
@@ -7233,32 +7472,6 @@ describe Braintree::Transaction do
|
|
7233
7472
|
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7234
7473
|
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionIsNotEligibleForAdjustment)
|
7235
7474
|
end
|
7236
|
-
|
7237
|
-
it "returns failure, when processor does not support incremental auth" do
|
7238
|
-
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7239
|
-
expect(initial_transaction.success?).to eq(true)
|
7240
|
-
|
7241
|
-
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7242
|
-
initial_transaction.transaction.id, "85.50"
|
7243
|
-
)
|
7244
|
-
|
7245
|
-
expect(adjustment_transaction.success?).to eq(false)
|
7246
|
-
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7247
|
-
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportIncrementalAuth)
|
7248
|
-
end
|
7249
|
-
|
7250
|
-
it "returns failure, when processor does not support auth reversal" do
|
7251
|
-
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7252
|
-
expect(initial_transaction.success?).to eq(true)
|
7253
|
-
|
7254
|
-
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7255
|
-
initial_transaction.transaction.id, "65.50"
|
7256
|
-
)
|
7257
|
-
|
7258
|
-
expect(adjustment_transaction.success?).to eq(false)
|
7259
|
-
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7260
|
-
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialAuthReversal)
|
7261
|
-
end
|
7262
7475
|
end
|
7263
7476
|
end
|
7264
7477
|
|