braintree 4.9.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/apple_pay_card.rb +2 -0
- data/lib/braintree/credit_card_verification_gateway.rb +18 -5
- data/lib/braintree/customer.rb +4 -1
- data/lib/braintree/dispute.rb +9 -0
- data/lib/braintree/dispute_search.rb +1 -0
- data/lib/braintree/error_codes.rb +7 -0
- data/lib/braintree/gateway.rb +4 -0
- data/lib/braintree/payment_instrument_type.rb +7 -6
- data/lib/braintree/payment_method_gateway.rb +2 -0
- data/lib/braintree/payment_method_nonce_details.rb +3 -0
- data/lib/braintree/payment_method_parser.rb +2 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/test/nonce.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +4 -0
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction.rb +6 -0
- data/lib/braintree/transaction_gateway.rb +1 -1
- data/lib/braintree/transaction_search.rb +1 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +76 -0
- data/lib/braintree.rb +4 -0
- data/spec/integration/braintree/credit_card_spec.rb +0 -60
- data/spec/integration/braintree/credit_card_verification_spec.rb +124 -1
- data/spec/integration/braintree/customer_spec.rb +1 -32
- data/spec/integration/braintree/dispute_search_spec.rb +28 -19
- data/spec/integration/braintree/dispute_spec.rb +27 -0
- data/spec/integration/braintree/http_spec.rb +1 -1
- data/spec/integration/braintree/paypal_account_spec.rb +2 -2
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/subscription_spec.rb +1 -1
- data/spec/integration/braintree/transaction_search_spec.rb +34 -2
- data/spec/integration/braintree/transaction_spec.rb +107 -101
- data/spec/integration/spec_helper.rb +6 -0
- data/spec/unit/braintree/apple_pay_card_spec.rb +99 -11
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/customer_spec.rb +11 -1
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +8 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +9 -1
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +16 -0
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_spec.rb +72 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +16 -0
- metadata +13 -3
@@ -1001,6 +1001,27 @@ describe Braintree::Transaction do
|
|
1001
1001
|
result.success?.should == false
|
1002
1002
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::TokenIssuance
|
1003
1003
|
end
|
1004
|
+
|
1005
|
+
xit "exposes the excessive_retry gateway rejection reason" do
|
1006
|
+
with_duplicate_checking_merchant do
|
1007
|
+
result = nil
|
1008
|
+
counter = 0
|
1009
|
+
excessive_retry = false
|
1010
|
+
until excessive_retry || counter == 20
|
1011
|
+
result = Braintree::Transaction.sale(
|
1012
|
+
:amount => Braintree::Test::TransactionAmounts::Decline,
|
1013
|
+
:credit_card => {
|
1014
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1015
|
+
:expiration_month => "05",
|
1016
|
+
:expiration_year => "2011"
|
1017
|
+
},
|
1018
|
+
)
|
1019
|
+
excessive_retry = result.transaction.status == "gateway_rejected"
|
1020
|
+
counter +=1
|
1021
|
+
end
|
1022
|
+
expect(result.transaction.gateway_rejection_reason). to eq(Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry)
|
1023
|
+
end
|
1024
|
+
end
|
1004
1025
|
end
|
1005
1026
|
|
1006
1027
|
it "accepts credit card expiration month and expiration year" do
|
@@ -1486,6 +1507,32 @@ describe Braintree::Transaction do
|
|
1486
1507
|
result.transaction.recurring.should == true
|
1487
1508
|
end
|
1488
1509
|
|
1510
|
+
it "successfully creates a transaction with installment_first" do
|
1511
|
+
result = Braintree::Transaction.create(
|
1512
|
+
:type => "sale",
|
1513
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1514
|
+
:credit_card => {
|
1515
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1516
|
+
:expiration_date => "12/12",
|
1517
|
+
},
|
1518
|
+
:transaction_source => "installment_first",
|
1519
|
+
)
|
1520
|
+
result.success?.should == true
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
it "successfully creates a transaction with installment" do
|
1524
|
+
result = Braintree::Transaction.create(
|
1525
|
+
:type => "sale",
|
1526
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1527
|
+
:credit_card => {
|
1528
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1529
|
+
:expiration_date => "12/12",
|
1530
|
+
},
|
1531
|
+
:transaction_source => "installment",
|
1532
|
+
)
|
1533
|
+
result.success?.should == true
|
1534
|
+
end
|
1535
|
+
|
1489
1536
|
it "marks a transactions as merchant" do
|
1490
1537
|
result = Braintree::Transaction.create(
|
1491
1538
|
:type => "sale",
|
@@ -1710,35 +1757,6 @@ describe Braintree::Transaction do
|
|
1710
1757
|
end
|
1711
1758
|
end
|
1712
1759
|
|
1713
|
-
describe "venmo_sdk" do
|
1714
|
-
it "can create a card with a venmo sdk payment method code" do
|
1715
|
-
result = Braintree::Transaction.create(
|
1716
|
-
:type => "sale",
|
1717
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1718
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
|
1719
|
-
)
|
1720
|
-
result.success?.should == true
|
1721
|
-
result.transaction.credit_card_details.bin.should == "400934"
|
1722
|
-
result.transaction.credit_card_details.last_4.should == "1881"
|
1723
|
-
end
|
1724
|
-
|
1725
|
-
it "can create a transaction with venmo sdk session" do
|
1726
|
-
result = Braintree::Transaction.create(
|
1727
|
-
:type => "sale",
|
1728
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1729
|
-
:credit_card => {
|
1730
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1731
|
-
:expiration_date => "12/12",
|
1732
|
-
},
|
1733
|
-
:options => {
|
1734
|
-
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
1735
|
-
},
|
1736
|
-
)
|
1737
|
-
result.success?.should == true
|
1738
|
-
result.transaction.credit_card_details.venmo_sdk?.should == false
|
1739
|
-
end
|
1740
|
-
end
|
1741
|
-
|
1742
1760
|
context "client API" do
|
1743
1761
|
it "can create a transaction with a shared card nonce" do
|
1744
1762
|
nonce = nonce_for_new_payment_method(
|
@@ -2687,7 +2705,7 @@ describe Braintree::Transaction do
|
|
2687
2705
|
it "can create a transaction" do
|
2688
2706
|
payment_method_result = Braintree::PaymentMethod.create(
|
2689
2707
|
:customer_id => Braintree::Customer.create.customer.id,
|
2690
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
2708
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
2691
2709
|
)
|
2692
2710
|
result = Braintree::Transaction.create(
|
2693
2711
|
:type => "sale",
|
@@ -4334,7 +4352,7 @@ describe Braintree::Transaction do
|
|
4334
4352
|
it "returns a validation error if used with an unsupported instrument type" do
|
4335
4353
|
customer = Braintree::Customer.create!
|
4336
4354
|
result = Braintree::PaymentMethod.create(
|
4337
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
4355
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
4338
4356
|
:customer_id => customer.id,
|
4339
4357
|
)
|
4340
4358
|
payment_method_token = result.payment_method.token
|
@@ -5208,7 +5226,50 @@ describe Braintree::Transaction do
|
|
5208
5226
|
end
|
5209
5227
|
end
|
5210
5228
|
|
5211
|
-
|
5229
|
+
|
5230
|
+
context "3rd party Card on File Network Token" do
|
5231
|
+
it "Works with all params" do
|
5232
|
+
params = {
|
5233
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5234
|
+
:credit_card => {
|
5235
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5236
|
+
:expiration_date => "05/2009",
|
5237
|
+
:network_tokenization_attributes => {
|
5238
|
+
:cryptogram => "/wAAAAAAAcb8AlGUF/1JQEkAAAA=",
|
5239
|
+
:ecommerce_indicator => "05",
|
5240
|
+
:token_requestor_id => "45310020105"
|
5241
|
+
},
|
5242
|
+
}
|
5243
|
+
}
|
5244
|
+
result = Braintree::Transaction.sale(params)
|
5245
|
+
expect(result.success?).to eq true
|
5246
|
+
expect(result.transaction.status).to eq Braintree::Transaction::Status::Authorized
|
5247
|
+
expect(result.transaction.processed_with_network_token?).to eq true
|
5248
|
+
|
5249
|
+
network_token_details = result.transaction.network_token_details
|
5250
|
+
expect(network_token_details.is_network_tokenized?).to eq true
|
5251
|
+
end
|
5252
|
+
|
5253
|
+
it "returns errors if validations on cryptogram fails" do
|
5254
|
+
params = {
|
5255
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5256
|
+
:credit_card => {
|
5257
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5258
|
+
:expiration_date => "05/2009",
|
5259
|
+
:network_tokenization_attributes => {
|
5260
|
+
:ecommerce_indicator => "05",
|
5261
|
+
:token_requestor_id => "45310020105"
|
5262
|
+
},
|
5263
|
+
}
|
5264
|
+
}
|
5265
|
+
result = Braintree::Transaction.sale(params)
|
5266
|
+
|
5267
|
+
expect(result.success?).to eq(false)
|
5268
|
+
expect(result.errors.for(:transaction).for(:credit_card).map { |e| e.code }.sort).to eq [Braintree::ErrorCodes::CreditCard::NetworkTokenizationAttributeCryptogramIsRequired]
|
5269
|
+
end
|
5270
|
+
end
|
5271
|
+
|
5272
|
+
xit "Amex Pay with Points" do
|
5212
5273
|
context "transaction creation" do
|
5213
5274
|
it "succeeds when submit_for_settlement is true" do
|
5214
5275
|
result = Braintree::Transaction.sale(
|
@@ -5517,7 +5578,7 @@ describe Braintree::Transaction do
|
|
5517
5578
|
end
|
5518
5579
|
end
|
5519
5580
|
|
5520
|
-
|
5581
|
+
xit "succeeds when level 2 data is provided" do
|
5521
5582
|
result = Braintree::Transaction.sale(
|
5522
5583
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5523
5584
|
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
@@ -5541,7 +5602,7 @@ describe Braintree::Transaction do
|
|
5541
5602
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5542
5603
|
end
|
5543
5604
|
|
5544
|
-
|
5605
|
+
xit "succeeds when level 3 data is provided" do
|
5545
5606
|
result = Braintree::Transaction.sale(
|
5546
5607
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5547
5608
|
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
@@ -6323,23 +6384,23 @@ describe Braintree::Transaction do
|
|
6323
6384
|
expect(transaction.three_d_secure_info.authentication).to have_key(:trans_status_reason)
|
6324
6385
|
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status)
|
6325
6386
|
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status_reason)
|
6326
|
-
transaction.three_d_secure_info.cavv.
|
6327
|
-
transaction.three_d_secure_info.ds_transaction_id.
|
6328
|
-
transaction.three_d_secure_info.eci_flag.
|
6329
|
-
transaction.three_d_secure_info.enrolled.
|
6330
|
-
transaction.three_d_secure_info.pares_status.
|
6331
|
-
transaction.three_d_secure_info.
|
6332
|
-
transaction.three_d_secure_info.
|
6333
|
-
transaction.three_d_secure_info.status.
|
6387
|
+
expect(transaction.three_d_secure_info.cavv).to eq("somebase64value")
|
6388
|
+
expect(transaction.three_d_secure_info.ds_transaction_id).to eq("dstxnid")
|
6389
|
+
expect(transaction.three_d_secure_info.eci_flag).to eq("07")
|
6390
|
+
expect(transaction.three_d_secure_info.enrolled).to eq("Y")
|
6391
|
+
expect(transaction.three_d_secure_info.pares_status).to eq("Y")
|
6392
|
+
expect(transaction.three_d_secure_info).to be_liability_shift_possible
|
6393
|
+
expect(transaction.three_d_secure_info).to be_liability_shifted
|
6394
|
+
expect(transaction.three_d_secure_info.status).to eq("authenticate_successful")
|
6334
6395
|
expect(transaction.three_d_secure_info.three_d_secure_authentication_id).to be
|
6335
|
-
transaction.three_d_secure_info.three_d_secure_version.
|
6336
|
-
transaction.three_d_secure_info.xid.
|
6396
|
+
expect(transaction.three_d_secure_info.three_d_secure_version).not_to be_nil
|
6397
|
+
expect(transaction.three_d_secure_info.xid).to eq("xidvalue")
|
6337
6398
|
end
|
6338
6399
|
|
6339
6400
|
it "is nil if the transaction wasn't 3d secured" do
|
6340
6401
|
transaction = Braintree::Transaction.find("settledtransaction")
|
6341
6402
|
|
6342
|
-
transaction.three_d_secure_info.
|
6403
|
+
expect(transaction.three_d_secure_info).to be_nil
|
6343
6404
|
end
|
6344
6405
|
end
|
6345
6406
|
|
@@ -6650,61 +6711,6 @@ describe Braintree::Transaction do
|
|
6650
6711
|
Braintree::Transaction.find(transaction.id)
|
6651
6712
|
end
|
6652
6713
|
|
6653
|
-
context "venmo sdk" do
|
6654
|
-
describe "venmo_sdk_payment_method_code" do
|
6655
|
-
it "can create a transaction with venmo_sdk_payment_method_code" do
|
6656
|
-
result = Braintree::Transaction.sale(
|
6657
|
-
:amount => "10.00",
|
6658
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa),
|
6659
|
-
)
|
6660
|
-
result.success?.should == true
|
6661
|
-
result.transaction.credit_card_details.venmo_sdk?.should == false
|
6662
|
-
end
|
6663
|
-
|
6664
|
-
it "errors when an invalid payment method code is passed" do
|
6665
|
-
result = Braintree::Transaction.sale(
|
6666
|
-
:amount => "10.00",
|
6667
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
|
6668
|
-
)
|
6669
|
-
result.success?.should == false
|
6670
|
-
result.message.should include("Invalid VenmoSDK payment method code")
|
6671
|
-
result.errors.map(&:code).should include("91727")
|
6672
|
-
end
|
6673
|
-
end
|
6674
|
-
|
6675
|
-
describe "venmo_sdk_session" do
|
6676
|
-
it "can create a transaction and vault a card when a venmo_sdk_session is present" do
|
6677
|
-
result = Braintree::Transaction.sale(
|
6678
|
-
:amount => "10.00",
|
6679
|
-
:credit_card => {
|
6680
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6681
|
-
:expiration_date => "05/2009"
|
6682
|
-
},
|
6683
|
-
:options => {
|
6684
|
-
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
6685
|
-
},
|
6686
|
-
)
|
6687
|
-
result.success?.should == true
|
6688
|
-
result.transaction.credit_card_details.venmo_sdk?.should == false
|
6689
|
-
end
|
6690
|
-
|
6691
|
-
it "venmo_sdk boolean is false when an invalid session is passed" do
|
6692
|
-
result = Braintree::Transaction.sale(
|
6693
|
-
:amount => "10.00",
|
6694
|
-
:credit_card => {
|
6695
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6696
|
-
:expiration_date => "05/2009"
|
6697
|
-
},
|
6698
|
-
:options => {
|
6699
|
-
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
6700
|
-
},
|
6701
|
-
)
|
6702
|
-
result.success?.should == true
|
6703
|
-
result.transaction.credit_card_details.venmo_sdk?.should == false
|
6704
|
-
end
|
6705
|
-
end
|
6706
|
-
end
|
6707
|
-
|
6708
6714
|
context "paypal" do
|
6709
6715
|
it "can create a transaction for a paypal account" do
|
6710
6716
|
result = Braintree::Transaction.sale(
|
@@ -7215,7 +7221,7 @@ describe Braintree::Transaction do
|
|
7215
7221
|
end
|
7216
7222
|
|
7217
7223
|
it "returns failure, when transaction authorization type final or undefined" do
|
7218
|
-
additional_params = {:transaction_source => "
|
7224
|
+
additional_params = {:transaction_source => "recurring"}
|
7219
7225
|
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7220
7226
|
expect(initial_transaction.success?).to eq(true)
|
7221
7227
|
|
@@ -67,4 +67,10 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
67
67
|
def random_payment_method_token
|
68
68
|
"payment-method-token-#{SecureRandom.hex(6)}"
|
69
69
|
end
|
70
|
+
|
71
|
+
def with_duplicate_checking_merchant(&block)
|
72
|
+
with_other_merchant("dup_checking_integration_merchant_id", "dup_checking_integration_public_key", "dup_checking_integration_private_key") do
|
73
|
+
block.call
|
74
|
+
end
|
75
|
+
end
|
70
76
|
end
|
@@ -1,35 +1,123 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
3
|
describe Braintree::ApplePayCard do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
let(:attributes) do
|
5
|
+
{
|
6
|
+
:billing_address => {
|
7
|
+
company: "Braintree",
|
8
|
+
country_code_alpha2: "US",
|
9
|
+
country_code_alpha3: "USA",
|
10
|
+
country_code_numeric: "840",
|
11
|
+
country_name: "United States of America",
|
12
|
+
extended_address: "Apt 1",
|
13
|
+
first_name: "John",
|
14
|
+
last_name: "Miller",
|
15
|
+
locality: "Chicago",
|
16
|
+
phone_number: "17708675309",
|
17
|
+
postal_code: "12345",
|
18
|
+
region: "Illinois",
|
19
|
+
street_address: "123 Sesame Street",
|
20
|
+
},
|
21
|
+
:bin => "411111",
|
22
|
+
:card_type => "Apple Pay - MasterCard",
|
23
|
+
:cardholder_name => "John Miller",
|
24
|
+
:commercial => "No",
|
25
|
+
:country_of_issuance => "USA",
|
26
|
+
:created_at => Time.now,
|
27
|
+
:customer_id => "cid1",
|
28
|
+
:debit => "No",
|
29
|
+
:default => true,
|
30
|
+
:durbin_regulated => "Yes",
|
31
|
+
:expiration_month => "01",
|
32
|
+
:expiration_year => "2025",
|
33
|
+
:expired => false,
|
34
|
+
:healthcare => "No",
|
35
|
+
:image_url => nil,
|
36
|
+
:issuing_bank => "Big Bad Bank",
|
37
|
+
:last_4 => "9876",
|
38
|
+
:payment_instrument_name => nil,
|
39
|
+
:payroll => "No",
|
40
|
+
:prepaid => "No",
|
41
|
+
:product_id => "MAC",
|
42
|
+
:source_description => "blah",
|
43
|
+
:subscriptions => [
|
44
|
+
{
|
45
|
+
balance: "50.00",
|
46
|
+
price: "10.00",
|
47
|
+
descriptor: [],
|
48
|
+
transactions: [],
|
49
|
+
add_ons: [],
|
50
|
+
discounts: [],
|
51
|
+
},
|
52
|
+
],
|
53
|
+
:token => "123456789",
|
54
|
+
:updated_at => Time.now,
|
55
|
+
}
|
8
56
|
end
|
9
57
|
|
10
|
-
describe "
|
11
|
-
it "
|
12
|
-
Braintree::ApplePayCard._new(:gateway,
|
58
|
+
describe "initialize" do
|
59
|
+
it "converts billing address hash to Braintree::Address object" do
|
60
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
61
|
+
|
62
|
+
expect(card.billing_address).to be_instance_of(Braintree::Address)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "converts subscriptions hash to Braintree::Subscription object" do
|
66
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
67
|
+
|
68
|
+
expect(card.subscriptions[0]).to be_instance_of(Braintree::Subscription)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "handles nil billing address" do
|
72
|
+
attributes.delete(:billing_address)
|
73
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
74
|
+
|
75
|
+
expect(card.billing_address).to be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it "handles nil subscriptions" do
|
79
|
+
attributes.delete(:subscriptions)
|
80
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
81
|
+
|
82
|
+
expect(card.subscriptions).to be_empty
|
13
83
|
end
|
14
84
|
end
|
15
85
|
|
16
86
|
describe "default?" do
|
17
87
|
it "is true if the Apple pay card is the default payment method for the customer" do
|
18
|
-
Braintree::ApplePayCard._new(:gateway,
|
88
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
89
|
+
|
90
|
+
expect(card.default?).to be true
|
19
91
|
end
|
20
92
|
|
21
93
|
it "is false if the Apple pay card is not the default payment methodfor the customer" do
|
22
|
-
|
94
|
+
attributes.merge!(:default => false)
|
95
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
96
|
+
|
97
|
+
expect(card.default?).to be false
|
23
98
|
end
|
24
99
|
end
|
25
100
|
|
26
101
|
describe "expired?" do
|
27
102
|
it "is true if the Apple pay card is expired" do
|
28
|
-
|
103
|
+
attributes.merge!(:expired => true)
|
104
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
105
|
+
|
106
|
+
expect(card.expired?).to be true
|
29
107
|
end
|
30
108
|
|
31
109
|
it "is false if the Apple pay card is not expired" do
|
32
|
-
Braintree::ApplePayCard._new(:gateway,
|
110
|
+
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
111
|
+
|
112
|
+
expect(card.expired?).to be false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "self.new" do
|
117
|
+
it "is protected" do
|
118
|
+
expect do
|
119
|
+
Braintree::ApplePayCard.new
|
120
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
33
121
|
end
|
34
122
|
end
|
35
123
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::CreditCardVerificationGateway do
|
4
|
+
describe "Credit Card Verification Gateway" 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 a credit card verification gateway" do
|
15
|
+
result = Braintree::CreditCardVerificationGateway.new(gateway)
|
16
|
+
|
17
|
+
result.inspect.should include("merchant_id")
|
18
|
+
result.inspect.should include("public_key")
|
19
|
+
result.inspect.should include("private_key")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "creates a credit card verification gateway signature" do
|
23
|
+
result = Braintree::CreditCardVerificationGateway._create_signature
|
24
|
+
result.inspect.should include("credit_card")
|
25
|
+
result.inspect.should include("credit_card")
|
26
|
+
result.inspect.should include("cardholder_name")
|
27
|
+
result.inspect.should include("cvv")
|
28
|
+
result.inspect.should include("expiration_date")
|
29
|
+
result.inspect.should include("expiration_month")
|
30
|
+
result.inspect.should include("expiration_year")
|
31
|
+
result.inspect.should include("number")
|
32
|
+
result.inspect.should include("billing_address")
|
33
|
+
result.inspect.should include("intended_transaction_source")
|
34
|
+
result.inspect.should include("options")
|
35
|
+
result.inspect.should include("amount")
|
36
|
+
result.inspect.should include("merchant_account_id")
|
37
|
+
result.inspect.should include("account_type")
|
38
|
+
result.inspect.should include("payment_method_nonce")
|
39
|
+
result.inspect.should include("three_d_secure_authentication_id")
|
40
|
+
result.inspect.should include("three_d_secure_pass_thru")
|
41
|
+
result.inspect.should include("eci_flag")
|
42
|
+
result.inspect.should include("cavv")
|
43
|
+
result.inspect.should include("xid")
|
44
|
+
result.inspect.should include("three_d_secure_version")
|
45
|
+
result.inspect.should include("authentication_response")
|
46
|
+
result.inspect.should include("directory_response")
|
47
|
+
result.inspect.should include("cavv_algorithm")
|
48
|
+
result.inspect.should include("ds_transaction_id")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -301,6 +301,10 @@ describe Braintree::Customer do
|
|
301
301
|
{:token => "paypal_1"},
|
302
302
|
{:token => "paypal_2"}
|
303
303
|
],
|
304
|
+
:sepa_debit_accounts => [
|
305
|
+
{:token => "sepa_debit_1"},
|
306
|
+
{:token => "sepa_debit_2"}
|
307
|
+
],
|
304
308
|
)
|
305
309
|
|
306
310
|
customer.credit_cards.size.should == 2
|
@@ -311,11 +315,17 @@ describe Braintree::Customer do
|
|
311
315
|
customer.paypal_accounts[0].token.should == "paypal_1"
|
312
316
|
customer.paypal_accounts[1].token.should == "paypal_2"
|
313
317
|
|
314
|
-
customer.
|
318
|
+
customer.sepa_direct_debit_accounts.size.should == 2
|
319
|
+
customer.sepa_direct_debit_accounts[0].token.should == "sepa_debit_1"
|
320
|
+
customer.sepa_direct_debit_accounts[1].token.should == "sepa_debit_2"
|
321
|
+
|
322
|
+
customer.payment_methods.count.should == 6
|
315
323
|
customer.payment_methods.map(&:token).should include("credit_card_1")
|
316
324
|
customer.payment_methods.map(&:token).should include("credit_card_2")
|
317
325
|
customer.payment_methods.map(&:token).should include("paypal_1")
|
318
326
|
customer.payment_methods.map(&:token).should include("paypal_2")
|
327
|
+
customer.payment_methods.map(&:token).should include("sepa_debit_1")
|
328
|
+
customer.payment_methods.map(&:token).should include("sepa_debit_2")
|
319
329
|
end
|
320
330
|
end
|
321
331
|
|
@@ -16,6 +16,7 @@ describe Braintree::Dispute do
|
|
16
16
|
:received_date => "2009-03-09",
|
17
17
|
:reply_by_date => nil,
|
18
18
|
:updated_at => Time.utc(2009, 3, 9, 10, 50, 39),
|
19
|
+
:pre_dispute_program => Braintree::Dispute::PreDisputeProgram::None,
|
19
20
|
:evidence => [
|
20
21
|
{
|
21
22
|
comment: nil,
|
@@ -428,6 +429,13 @@ describe Braintree::Dispute do
|
|
428
429
|
dispute.date_opened.should == Date.new(2009, 3, 9)
|
429
430
|
dispute.date_won.should == Date.new(2009, 4, 15)
|
430
431
|
end
|
432
|
+
|
433
|
+
it "returns pre_dispute_program value" do
|
434
|
+
attributes.merge!(:pre_dispute_program => Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
435
|
+
dispute = Braintree::Dispute._new(attributes)
|
436
|
+
|
437
|
+
expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
438
|
+
end
|
431
439
|
end
|
432
440
|
|
433
441
|
describe "==" do
|
@@ -3,12 +3,16 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
3
3
|
describe Braintree::PaymentMethodNonceDetails do
|
4
4
|
let(:payment_method_nonce_details) {
|
5
5
|
Braintree::PaymentMethodNonceDetails.new(
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
6
7
|
:bin => "bin",
|
7
8
|
:card_type => "American Express",
|
8
9
|
:expiration_month => "12",
|
9
10
|
:expiration_year => "2025",
|
10
11
|
:is_network_tokenized => true,
|
12
|
+
:last_4 => "abcd",
|
11
13
|
:last_two => "11",
|
14
|
+
:mandate_type => "ONE_OFF",
|
15
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
12
16
|
:payer_info => {
|
13
17
|
:billing_agreement_id => "1234",
|
14
18
|
:country_code => "US",
|
@@ -26,12 +30,16 @@ describe Braintree::PaymentMethodNonceDetails do
|
|
26
30
|
payment_method_nonce_details.last_two.should == "11"
|
27
31
|
payment_method_nonce_details.payer_info.billing_agreement_id.should == "1234"
|
28
32
|
payment_method_nonce_details.payer_info.country_code.should == "US"
|
33
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token.should == "a-bank-reference-token"
|
34
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4.should == "abcd"
|
35
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type.should == "ONE_OFF"
|
36
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id.should == "a-mp-customer-id"
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
40
|
describe "inspect" do
|
33
41
|
it "prints the attributes" do
|
34
|
-
payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>>)
|
42
|
+
payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>)
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::SepaDirectDebitAccountNonceDetails do
|
4
|
+
subject do
|
5
|
+
described_class.new(
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
7
|
+
:last_4 => "abcd",
|
8
|
+
:mandate_type => "ONE_OFF",
|
9
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "sets attributes" do
|
15
|
+
is_expected.to have_attributes(
|
16
|
+
:bank_reference_token => "a-bank-reference-token",
|
17
|
+
:last_4 => "abcd",
|
18
|
+
:mandate_type => "ONE_OFF",
|
19
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "inspect" do
|
25
|
+
it "prints the attributes" do
|
26
|
+
subject.inspect.should == %(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|