braintree 4.30.0 → 4.32.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/address_gateway.rb +5 -0
- data/lib/braintree/apple_pay_card.rb +1 -0
- data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
- data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
- data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
- data/lib/braintree/error_codes.rb +12 -0
- data/lib/braintree/gateway.rb +4 -0
- data/lib/braintree/payment_method_gateway.rb +6 -0
- data/lib/braintree/successful_result.rb +1 -0
- data/lib/braintree/transaction/apple_pay_details.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +2 -0
- data/lib/braintree/transaction/google_pay_details.rb +1 -0
- data/lib/braintree/transaction.rb +1 -0
- data/lib/braintree/transaction_gateway.rb +25 -1
- data/lib/braintree/us_bank_account_verification.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree.rb +3 -0
- data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +7 -0
- data/spec/integration/braintree/payment_method_spec.rb +3 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/transaction_search_spec.rb +26 -24
- data/spec/integration/braintree/transaction_spec.rb +117 -3
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +255 -0
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
- data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/braintree/apple_pay_card_spec.rb +2 -0
- data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
- data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +9 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +10 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +9 -0
- data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +21 -1
- data/spec/unit/braintree/transaction_spec.rb +48 -0
- metadata +13 -7
- data/lib/ssl/securetrust_ca.crt +0 -44
|
@@ -176,6 +176,16 @@ describe Braintree::Transaction, "search" do
|
|
|
176
176
|
expect(collection.first.id).to eq(transaction_id)
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
+
it "searches on reason_codes for 3 items" do
|
|
180
|
+
reason_code = ["R01", "R02"]
|
|
181
|
+
|
|
182
|
+
collection = Braintree::Transaction.search do |search|
|
|
183
|
+
search.reason_code.in reason_code
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
expect(collection.maximum_size).to eq(3)
|
|
187
|
+
end
|
|
188
|
+
|
|
179
189
|
it "searches on reason_code" do
|
|
180
190
|
transaction_id = "ach_txn_ret1"
|
|
181
191
|
reason_code = "R01"
|
|
@@ -184,9 +194,24 @@ describe Braintree::Transaction, "search" do
|
|
|
184
194
|
search.reason_code.in reason_code
|
|
185
195
|
end
|
|
186
196
|
item = collection.find { |t| t.id == transaction_id }
|
|
197
|
+
expect(item.ach_return_code).to eq("R01")
|
|
187
198
|
expect(item.ach_return_responses.first[:reason_code]).to eq("R01")
|
|
188
199
|
end
|
|
189
200
|
|
|
201
|
+
it "searches on rejections reason_code" do
|
|
202
|
+
transaction_id = "ach_txn_ret3"
|
|
203
|
+
reason_code = "RJCT"
|
|
204
|
+
|
|
205
|
+
collection = Braintree::Transaction.search do |search|
|
|
206
|
+
search.reason_code.in reason_code
|
|
207
|
+
end
|
|
208
|
+
item = collection.find { |t| t.id == transaction_id }
|
|
209
|
+
expect(item.ach_return_code).to eq("RJCT")
|
|
210
|
+
expect(item.ach_reject_reason).to eq("Bank accounts located outside of the U.S. are not supported.")
|
|
211
|
+
expect(item.ach_return_responses.first[:reason_code]).to eq("RJCT")
|
|
212
|
+
expect(item.ach_return_responses.first[:reject_reason]).to eq("Bank accounts located outside of the U.S. are not supported.")
|
|
213
|
+
end
|
|
214
|
+
|
|
190
215
|
it "searches on reason_codes" do
|
|
191
216
|
reason_code = "any_reason_code"
|
|
192
217
|
|
|
@@ -194,7 +219,7 @@ describe Braintree::Transaction, "search" do
|
|
|
194
219
|
search.reason_code.is reason_code
|
|
195
220
|
end
|
|
196
221
|
|
|
197
|
-
expect(collection.maximum_size).to eq(
|
|
222
|
+
expect(collection.maximum_size).to eq(6)
|
|
198
223
|
end
|
|
199
224
|
|
|
200
225
|
context "multiple value fields" do
|
|
@@ -588,29 +613,6 @@ describe Braintree::Transaction, "search" do
|
|
|
588
613
|
expect(collection.first.id).to eq(transaction_id)
|
|
589
614
|
end
|
|
590
615
|
|
|
591
|
-
it "searches on reason_codes for 3 items" do
|
|
592
|
-
reason_code = ["R01", "R02"]
|
|
593
|
-
|
|
594
|
-
collection = Braintree::Transaction.search do |search|
|
|
595
|
-
search.reason_code.in reason_code
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
expect(collection.maximum_size).to eq(3)
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
xit "searches on a reason_code" do
|
|
602
|
-
# duplicate test
|
|
603
|
-
reason_code = ["R01"]
|
|
604
|
-
transaction_id = "ach_txn_ret1"
|
|
605
|
-
|
|
606
|
-
collection = Braintree::Transaction.search do |search|
|
|
607
|
-
search.reason_code.in reason_code
|
|
608
|
-
end
|
|
609
|
-
|
|
610
|
-
expect(collection.maximum_size).to eq(1)
|
|
611
|
-
expect(collection.first.id).to eq(transaction_id)
|
|
612
|
-
end
|
|
613
|
-
|
|
614
616
|
xit "searches on debit_network" do
|
|
615
617
|
transaction = Braintree::Transaction.sale!(
|
|
616
618
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
@@ -2214,6 +2214,37 @@ describe Braintree::Transaction do
|
|
|
2214
2214
|
expect(apple_pay_details.commercial).not_to be_nil
|
|
2215
2215
|
expect(apple_pay_details.payroll).not_to be_nil
|
|
2216
2216
|
expect(apple_pay_details.product_id).not_to be_nil
|
|
2217
|
+
expect(apple_pay_details.is_device_token).to eq(true)
|
|
2218
|
+
end
|
|
2219
|
+
|
|
2220
|
+
it "can create a transaction with a fake apple pay mpan nonce" do
|
|
2221
|
+
result = Braintree::Transaction.create(
|
|
2222
|
+
:type => "sale",
|
|
2223
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
2224
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayMpan,
|
|
2225
|
+
)
|
|
2226
|
+
expect(result.success?).to eq(true)
|
|
2227
|
+
expect(result.transaction).not_to be_nil
|
|
2228
|
+
apple_pay_details = result.transaction.apple_pay_details
|
|
2229
|
+
expect(apple_pay_details).not_to be_nil
|
|
2230
|
+
expect(apple_pay_details.bin).not_to be_nil
|
|
2231
|
+
expect(apple_pay_details.card_type).to eq(Braintree::ApplePayCard::CardType::Visa)
|
|
2232
|
+
expect(apple_pay_details.payment_instrument_name).to eq("Visa 2006")
|
|
2233
|
+
expect(apple_pay_details.source_description).to eq("Visa 2006")
|
|
2234
|
+
expect(apple_pay_details.expiration_month.to_i).to be > 0
|
|
2235
|
+
expect(apple_pay_details.expiration_year.to_i).to be > 0
|
|
2236
|
+
expect(apple_pay_details.cardholder_name).not_to be_nil
|
|
2237
|
+
expect(apple_pay_details.image_url).not_to be_nil
|
|
2238
|
+
expect(apple_pay_details.token).to be_nil
|
|
2239
|
+
expect(apple_pay_details.prepaid).not_to be_nil
|
|
2240
|
+
expect(apple_pay_details.healthcare).not_to be_nil
|
|
2241
|
+
expect(apple_pay_details.debit).not_to be_nil
|
|
2242
|
+
expect(apple_pay_details.durbin_regulated).not_to be_nil
|
|
2243
|
+
expect(apple_pay_details.commercial).not_to be_nil
|
|
2244
|
+
expect(apple_pay_details.payroll).not_to be_nil
|
|
2245
|
+
expect(apple_pay_details.product_id).not_to be_nil
|
|
2246
|
+
expect(apple_pay_details.merchant_token_identifier).not_to be_nil
|
|
2247
|
+
expect(apple_pay_details.is_device_token).to eq(false)
|
|
2217
2248
|
end
|
|
2218
2249
|
|
|
2219
2250
|
it "can create a vaulted transaction with a fake apple pay nonce" do
|
|
@@ -2304,9 +2335,9 @@ describe Braintree::Transaction do
|
|
|
2304
2335
|
expect(google_pay_details).not_to be_nil
|
|
2305
2336
|
expect(google_pay_details.card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
2306
2337
|
expect(google_pay_details.virtual_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
2307
|
-
expect(google_pay_details.last_4).to eq("
|
|
2308
|
-
expect(google_pay_details.virtual_card_last_4).to eq("
|
|
2309
|
-
expect(google_pay_details.source_description).to eq("MasterCard
|
|
2338
|
+
expect(google_pay_details.last_4).to eq("0005")
|
|
2339
|
+
expect(google_pay_details.virtual_card_last_4).to eq("0005")
|
|
2340
|
+
expect(google_pay_details.source_description).to eq("MasterCard 0005")
|
|
2310
2341
|
expect(google_pay_details.expiration_month.to_i).to be > 0
|
|
2311
2342
|
expect(google_pay_details.expiration_year.to_i).to be > 0
|
|
2312
2343
|
expect(google_pay_details.google_transaction_id).to eq("google_transaction_id")
|
|
@@ -5270,6 +5301,61 @@ describe Braintree::Transaction do
|
|
|
5270
5301
|
expect(transaction.shipping_details.international_phone[:national_number]).to eq("3121234567")
|
|
5271
5302
|
end
|
|
5272
5303
|
|
|
5304
|
+
it "accepts processing_merchant_category_code" do
|
|
5305
|
+
result = Braintree::Transaction.sale(
|
|
5306
|
+
:amount => "100.00",
|
|
5307
|
+
:credit_card => {
|
|
5308
|
+
:number => "4111111111111111",
|
|
5309
|
+
:expiration_date => "05/2028"
|
|
5310
|
+
},
|
|
5311
|
+
:processing_merchant_category_code => "5411",
|
|
5312
|
+
)
|
|
5313
|
+
|
|
5314
|
+
expect(result.success?).to eq(true)
|
|
5315
|
+
end
|
|
5316
|
+
|
|
5317
|
+
it "returns validation error for a too long processing_merchant_category_code" do
|
|
5318
|
+
result = Braintree::Transaction.sale(
|
|
5319
|
+
:amount => "100.00",
|
|
5320
|
+
:credit_card => {
|
|
5321
|
+
:number => "4111111111111111",
|
|
5322
|
+
:expiration_date => "05/2028"
|
|
5323
|
+
},
|
|
5324
|
+
:processing_merchant_category_code => "54111",
|
|
5325
|
+
)
|
|
5326
|
+
|
|
5327
|
+
expect(result.success?).to eq(false)
|
|
5328
|
+
expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
|
|
5329
|
+
end
|
|
5330
|
+
|
|
5331
|
+
it "returns validation error for an alphanumeric processing_merchant_category_code" do
|
|
5332
|
+
result = Braintree::Transaction.sale(
|
|
5333
|
+
:amount => "100.00",
|
|
5334
|
+
:credit_card => {
|
|
5335
|
+
:number => "4111111111111111",
|
|
5336
|
+
:expiration_date => "05/2028"
|
|
5337
|
+
},
|
|
5338
|
+
:processing_merchant_category_code => "541A",
|
|
5339
|
+
)
|
|
5340
|
+
|
|
5341
|
+
expect(result.success?).to eq(false)
|
|
5342
|
+
expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
|
|
5343
|
+
end
|
|
5344
|
+
|
|
5345
|
+
it "returns validation error for a too short processing_merchant_category_code" do
|
|
5346
|
+
result = Braintree::Transaction.sale(
|
|
5347
|
+
:amount => "100.00",
|
|
5348
|
+
:credit_card => {
|
|
5349
|
+
:number => "4111111111111111",
|
|
5350
|
+
:expiration_date => "05/2028"
|
|
5351
|
+
},
|
|
5352
|
+
:processing_merchant_category_code => "541",
|
|
5353
|
+
)
|
|
5354
|
+
|
|
5355
|
+
expect(result.success?).to eq(false)
|
|
5356
|
+
expect(result.errors.for(:transaction).on(:processing_merchant_category_code)[0].code).to eq(Braintree::ErrorCodes::Transaction::ProcessingMerchantCategoryCodeIsInvalid)
|
|
5357
|
+
end
|
|
5358
|
+
|
|
5273
5359
|
it "allows merchant account to be specified" do
|
|
5274
5360
|
result = Braintree::Transaction.sale(
|
|
5275
5361
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
@@ -6784,6 +6870,34 @@ describe Braintree::Transaction do
|
|
|
6784
6870
|
expect(transaction.acquirer_reference_number).to eq("123456789 091019")
|
|
6785
6871
|
end
|
|
6786
6872
|
|
|
6873
|
+
it "finds a transaction and returns a payment_account_reference if the transaction has one" do
|
|
6874
|
+
transaction = Braintree::Transaction.find("aft_txn")
|
|
6875
|
+
|
|
6876
|
+
expect(transaction.credit_card_details).not_to be_nil
|
|
6877
|
+
expect(transaction.credit_card_details).to respond_to(:payment_account_reference)
|
|
6878
|
+
end
|
|
6879
|
+
|
|
6880
|
+
it "finds a transaction and returns a payment_account_reference in apple_pay_details if the transaction has one" do
|
|
6881
|
+
transaction = Braintree::Transaction.find("apple_pay_transaction")
|
|
6882
|
+
|
|
6883
|
+
expect(transaction.apple_pay_details).not_to be_nil
|
|
6884
|
+
expect(transaction.apple_pay_details).to respond_to(:payment_account_reference)
|
|
6885
|
+
end
|
|
6886
|
+
|
|
6887
|
+
it "finds a transaction and returns a payment_account_reference in google_pay_details if the transaction has one" do
|
|
6888
|
+
transaction = Braintree::Transaction.find("android_pay_card_transaction")
|
|
6889
|
+
|
|
6890
|
+
expect(transaction.google_pay_details).not_to be_nil
|
|
6891
|
+
expect(transaction.google_pay_details).to respond_to(:payment_account_reference)
|
|
6892
|
+
end
|
|
6893
|
+
|
|
6894
|
+
it "finds a transaction and returns a payment_account_reference in google_pay_details for network token if the transaction has one" do
|
|
6895
|
+
transaction = Braintree::Transaction.find("android_pay_network_token_transaction")
|
|
6896
|
+
|
|
6897
|
+
expect(transaction.google_pay_details).not_to be_nil
|
|
6898
|
+
expect(transaction.google_pay_details).to respond_to(:payment_account_reference)
|
|
6899
|
+
end
|
|
6900
|
+
|
|
6787
6901
|
context "disbursement_details" do
|
|
6788
6902
|
it "includes disbursement_details on found transactions" do
|
|
6789
6903
|
found_transaction = Braintree::Transaction.find("deposittransaction")
|
|
@@ -42,5 +42,260 @@ describe Braintree::Transaction do
|
|
|
42
42
|
result = Braintree::Transaction.sale(transaction_params)
|
|
43
43
|
expect(result.success?).to eq(false)
|
|
44
44
|
end
|
|
45
|
+
|
|
46
|
+
it "should create a transaction with valid transfer types and merchant account id" do
|
|
47
|
+
SpecHelper::SdwoSupportedTransferTypes.each do |transfer_type|
|
|
48
|
+
transaction_params = {
|
|
49
|
+
:type => "sale",
|
|
50
|
+
:amount => "100.00",
|
|
51
|
+
:merchant_account_id => "card_processor_brl_sdwo",
|
|
52
|
+
:credit_card => {
|
|
53
|
+
:number => "4111111111111111",
|
|
54
|
+
:expiration_date => "06/2026",
|
|
55
|
+
:cvv => "123"
|
|
56
|
+
},
|
|
57
|
+
:descriptor => {
|
|
58
|
+
:name => "companynme12*product1",
|
|
59
|
+
:phone => "1232344444",
|
|
60
|
+
:url => "example.com",
|
|
61
|
+
},
|
|
62
|
+
:billing => {
|
|
63
|
+
:first_name => "Bob James",
|
|
64
|
+
:country_code_alpha2 => "CA",
|
|
65
|
+
:extended_address => "",
|
|
66
|
+
:locality => "Trois-Rivires",
|
|
67
|
+
:region => "QC",
|
|
68
|
+
:postal_code => "G8Y 156",
|
|
69
|
+
:street_address => "2346 Boul Lane",
|
|
70
|
+
},
|
|
71
|
+
:transfer => {
|
|
72
|
+
:type => transfer_type,
|
|
73
|
+
:sender => {
|
|
74
|
+
:first_name => "Alice",
|
|
75
|
+
:last_name => "Silva",
|
|
76
|
+
:account_reference_number => "1000012345",
|
|
77
|
+
:tax_id => "12345678900",
|
|
78
|
+
:address => {
|
|
79
|
+
:street_address => "Rua das Flores, 100",
|
|
80
|
+
:extended_address => "2B",
|
|
81
|
+
:locality => "São Paulo",
|
|
82
|
+
:region => "SP",
|
|
83
|
+
:postal_code => "01001-000",
|
|
84
|
+
:country_code_alpha2 => "BR",
|
|
85
|
+
:international_phone => {
|
|
86
|
+
:country_code => "55",
|
|
87
|
+
:national_number => "1234567890"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
:receiver => {
|
|
92
|
+
:first_name => "Bob",
|
|
93
|
+
:last_name => "Souza",
|
|
94
|
+
:account_reference_number => "2000012345",
|
|
95
|
+
:tax_id => "98765432100",
|
|
96
|
+
:address => {
|
|
97
|
+
:street_address => "Avenida Brasil, 200",
|
|
98
|
+
:extended_address => "2B",
|
|
99
|
+
:locality => "Rio de Janeiro",
|
|
100
|
+
:region => "RJ",
|
|
101
|
+
:postal_code => "20040-002",
|
|
102
|
+
:country_code_alpha2 => "BR",
|
|
103
|
+
:international_phone => {
|
|
104
|
+
:country_code => "55",
|
|
105
|
+
:national_number => "9876543210"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
:options => {
|
|
111
|
+
:store_in_vault_on_success => true,
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
result = Braintree::Transaction.sale(transaction_params)
|
|
116
|
+
expect(result.success?).to eq(true)
|
|
117
|
+
expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "should fail when transfer details are not provided" do
|
|
122
|
+
transaction_params = {
|
|
123
|
+
:type => "sale",
|
|
124
|
+
:amount => "100.00",
|
|
125
|
+
:merchant_account_id => "card_processor_brl_sdwo",
|
|
126
|
+
:credit_card => {
|
|
127
|
+
:number => "4111111111111111",
|
|
128
|
+
:expiration_date => "06/2026",
|
|
129
|
+
:cvv => "123"
|
|
130
|
+
},
|
|
131
|
+
:descriptor => {
|
|
132
|
+
:name => "companynme12*product1",
|
|
133
|
+
:phone => "1232344444",
|
|
134
|
+
:url => "example.com",
|
|
135
|
+
},
|
|
136
|
+
:billing => {
|
|
137
|
+
:first_name => "Bob James",
|
|
138
|
+
:country_code_alpha2 => "CA",
|
|
139
|
+
:extended_address => "",
|
|
140
|
+
:locality => "Trois-Rivires",
|
|
141
|
+
:region => "QC",
|
|
142
|
+
:postal_code => "G8Y 156",
|
|
143
|
+
:street_address => "2346 Boul Lane",
|
|
144
|
+
},
|
|
145
|
+
:options => {
|
|
146
|
+
:store_in_vault_on_success => true,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
result = Braintree::Transaction.sale(transaction_params)
|
|
151
|
+
expect(result.success?).to eq(false)
|
|
152
|
+
expect(result.errors.for(:transaction).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionTransferDetailsAreMandatory)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should fail on transaction with invalid transfer type" do
|
|
156
|
+
transaction_params = {
|
|
157
|
+
:type => "sale",
|
|
158
|
+
:amount => "100.00",
|
|
159
|
+
:merchant_account_id => "card_processor_brl_sdwo",
|
|
160
|
+
:credit_card => {
|
|
161
|
+
:number => "4111111111111111",
|
|
162
|
+
:expiration_date => "06/2026",
|
|
163
|
+
:cvv => "123"
|
|
164
|
+
},
|
|
165
|
+
:descriptor => {
|
|
166
|
+
:name => "companynme12*product1",
|
|
167
|
+
:phone => "1232344444",
|
|
168
|
+
:url => "example.com",
|
|
169
|
+
},
|
|
170
|
+
:billing => {
|
|
171
|
+
:first_name => "Bob James",
|
|
172
|
+
:country_code_alpha2 => "CA",
|
|
173
|
+
:extended_address => "",
|
|
174
|
+
:locality => "Trois-Rivires",
|
|
175
|
+
:region => "QC",
|
|
176
|
+
:postal_code => "G8Y 156",
|
|
177
|
+
:street_address => "2346 Boul Lane",
|
|
178
|
+
},
|
|
179
|
+
:transfer => {
|
|
180
|
+
:type => "invalid_transfer_type",
|
|
181
|
+
:sender => {
|
|
182
|
+
:first_name => "Alice",
|
|
183
|
+
:last_name => "Silva",
|
|
184
|
+
:account_reference_number => "1000012345",
|
|
185
|
+
:tax_id => "12345678900",
|
|
186
|
+
:address => {
|
|
187
|
+
:street_address => "Rua das Flores, 100",
|
|
188
|
+
:extended_address => "2B",
|
|
189
|
+
:locality => "São Paulo",
|
|
190
|
+
:region => "SP",
|
|
191
|
+
:postal_code => "01001-000",
|
|
192
|
+
:country_code_alpha2 => "BR",
|
|
193
|
+
:international_phone => {
|
|
194
|
+
:country_code => "55",
|
|
195
|
+
:national_number => "1234567890"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
:receiver => {
|
|
200
|
+
:first_name => "Bob",
|
|
201
|
+
:last_name => "Souza",
|
|
202
|
+
:account_reference_number => "2000012345",
|
|
203
|
+
:tax_id => "98765432100",
|
|
204
|
+
:address => {
|
|
205
|
+
:street_address => "Avenida Brasil, 200",
|
|
206
|
+
:extended_address => "2B",
|
|
207
|
+
:locality => "Rio de Janeiro",
|
|
208
|
+
:region => "RJ",
|
|
209
|
+
:postal_code => "20040-002",
|
|
210
|
+
:country_code_alpha2 => "BR",
|
|
211
|
+
:international_phone => {
|
|
212
|
+
:country_code => "55",
|
|
213
|
+
:national_number => "9876543210"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
:options => {
|
|
219
|
+
:store_in_vault_on_success => true,
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
result = Braintree::Transaction.sale(transaction_params)
|
|
224
|
+
expect(result.success?).to eq(false)
|
|
225
|
+
expect(result.errors.for(:account_funding_transaction).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionTransferTypeIsInvalid)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "should create a transaction when transfer type is nil" do
|
|
229
|
+
transaction_params = {
|
|
230
|
+
:type => "sale",
|
|
231
|
+
:amount => "100.00",
|
|
232
|
+
:merchant_account_id => "card_processor_brl_sdwo",
|
|
233
|
+
:credit_card => {
|
|
234
|
+
:number => "4111111111111111",
|
|
235
|
+
:expiration_date => "06/2026",
|
|
236
|
+
:cvv => "123"
|
|
237
|
+
},
|
|
238
|
+
:descriptor => {
|
|
239
|
+
:name => "companynme12*product1",
|
|
240
|
+
:phone => "1232344444",
|
|
241
|
+
:url => "example.com",
|
|
242
|
+
},
|
|
243
|
+
:billing => {
|
|
244
|
+
:first_name => "Bob James",
|
|
245
|
+
:country_code_alpha2 => "CA",
|
|
246
|
+
:extended_address => "",
|
|
247
|
+
:locality => "Trois-Rivires",
|
|
248
|
+
:region => "QC",
|
|
249
|
+
:postal_code => "G8Y 156",
|
|
250
|
+
:street_address => "2346 Boul Lane",
|
|
251
|
+
},
|
|
252
|
+
:transfer => {
|
|
253
|
+
:type => nil,
|
|
254
|
+
:sender => {
|
|
255
|
+
:first_name => "Alice",
|
|
256
|
+
:last_name => "Silva",
|
|
257
|
+
:account_reference_number => "1000012345",
|
|
258
|
+
:tax_id => "12345678900",
|
|
259
|
+
:address => {
|
|
260
|
+
:street_address => "Rua das Flores, 100",
|
|
261
|
+
:extended_address => "2B",
|
|
262
|
+
:locality => "São Paulo",
|
|
263
|
+
:region => "SP",
|
|
264
|
+
:postal_code => "01001-000",
|
|
265
|
+
:country_code_alpha2 => "BR",
|
|
266
|
+
:international_phone => {
|
|
267
|
+
:country_code => "55",
|
|
268
|
+
:national_number => "1234567890"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
:receiver => {
|
|
273
|
+
:first_name => "Bob",
|
|
274
|
+
:last_name => "Souza",
|
|
275
|
+
:account_reference_number => "2000012345",
|
|
276
|
+
:tax_id => "98765432100",
|
|
277
|
+
:address => {
|
|
278
|
+
:street_address => "Avenida Brasil, 200",
|
|
279
|
+
:extended_address => "2B",
|
|
280
|
+
:locality => "Rio de Janeiro",
|
|
281
|
+
:region => "RJ",
|
|
282
|
+
:postal_code => "20040-002",
|
|
283
|
+
:country_code_alpha2 => "BR",
|
|
284
|
+
:international_phone => {
|
|
285
|
+
:country_code => "55",
|
|
286
|
+
:national_number => "9876543210"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
:options => {
|
|
292
|
+
:store_in_vault_on_success => true,
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
result = Braintree::Transaction.sale(transaction_params)
|
|
297
|
+
expect(result.success?).to eq(true)
|
|
298
|
+
expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
|
299
|
+
end
|
|
45
300
|
end
|
|
46
301
|
end
|
|
@@ -140,7 +140,6 @@ describe Braintree::Transaction do
|
|
|
140
140
|
expect(transaction.us_bank_account_details.account_type).to eq("checking")
|
|
141
141
|
expect(transaction.us_bank_account_details.account_holder_name).to eq("John Doe")
|
|
142
142
|
expect(transaction.us_bank_account_details.bank_name).to match(/CHASE/)
|
|
143
|
-
expect(transaction.us_bank_account_details.ach_mandate.text).to eq("cl mandate text")
|
|
144
143
|
expect(transaction.us_bank_account_details.ach_mandate.accepted_at).to be_a Time
|
|
145
144
|
end
|
|
146
145
|
|
|
@@ -23,7 +23,6 @@ describe Braintree::UsBankAccount do
|
|
|
23
23
|
expect(us_bank_account.account_type).to eq("checking")
|
|
24
24
|
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
25
25
|
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
26
|
-
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
27
26
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
28
27
|
end
|
|
29
28
|
|
|
@@ -63,7 +62,6 @@ describe Braintree::UsBankAccount do
|
|
|
63
62
|
expect(us_bank_account.account_type).to eq("checking")
|
|
64
63
|
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
65
64
|
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
66
|
-
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
67
65
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
68
66
|
end
|
|
69
67
|
end
|
|
@@ -96,7 +94,6 @@ describe Braintree::UsBankAccount do
|
|
|
96
94
|
expect(us_bank_account.account_type).to eq("checking")
|
|
97
95
|
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
98
96
|
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
99
|
-
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
100
97
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
101
98
|
end
|
|
102
99
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -77,6 +77,13 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
77
77
|
:billing_day_of_month => 5
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
SdwoSupportedTransferTypes = [
|
|
81
|
+
"account_to_account",
|
|
82
|
+
"boleto_ticket",
|
|
83
|
+
"person_to_person",
|
|
84
|
+
"wallet_transfer"
|
|
85
|
+
]
|
|
86
|
+
|
|
80
87
|
AddOnIncrease10 = "increase_10"
|
|
81
88
|
AddOnIncrease20 = "increase_20"
|
|
82
89
|
AddOnIncrease30 = "increase_30"
|
|
@@ -36,6 +36,7 @@ describe Braintree::ApplePayCard do
|
|
|
36
36
|
:expired => false,
|
|
37
37
|
:healthcare => "No",
|
|
38
38
|
:image_url => nil,
|
|
39
|
+
:is_device_token => false,
|
|
39
40
|
:issuing_bank => "Big Bad Bank",
|
|
40
41
|
:last_4 => "9876",
|
|
41
42
|
:merchant_token_identifier => "merchant-token-123",
|
|
@@ -93,6 +94,7 @@ describe Braintree::ApplePayCard do
|
|
|
93
94
|
card = Braintree::ApplePayCard._new(:gateway, attributes)
|
|
94
95
|
|
|
95
96
|
expect(card.merchant_token_identifier).to_not be_nil
|
|
97
|
+
expect(card.is_device_token).to_not be_nil
|
|
96
98
|
expect(card.source_card_last4).to_not be_nil
|
|
97
99
|
end
|
|
98
100
|
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::BankAccountInstantVerificationGateway do
|
|
4
|
+
let(:gateway) { double("gateway") }
|
|
5
|
+
let(:config) { double("config") }
|
|
6
|
+
let(:graphql_client) { double("graphql_client") }
|
|
7
|
+
let(:bank_account_instant_verification_gateway) { Braintree::BankAccountInstantVerificationGateway.new(gateway) }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
allow(gateway).to receive(:config).and_return(config)
|
|
11
|
+
allow(gateway).to receive(:graphql_client).and_return(graphql_client)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "create_jwt" do
|
|
15
|
+
let(:request) do
|
|
16
|
+
Braintree::BankAccountInstantVerificationJwtRequest.new(
|
|
17
|
+
:business_name => "Test Business",
|
|
18
|
+
:return_url => "https://example.com/success",
|
|
19
|
+
:cancel_url => "https://example.com/cancel",
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "returns success result with valid response" do
|
|
24
|
+
mock_response = {
|
|
25
|
+
:data => {
|
|
26
|
+
:createBankAccountInstantVerificationJwt => {
|
|
27
|
+
:jwt => "test-jwt-token"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
allow(graphql_client).to receive(:query).and_return(mock_response)
|
|
33
|
+
|
|
34
|
+
result = bank_account_instant_verification_gateway.create_jwt(request)
|
|
35
|
+
|
|
36
|
+
expect(result.success?).to eq(true)
|
|
37
|
+
expect(result.bank_account_instant_verification_jwt).not_to be_nil
|
|
38
|
+
expect(result.bank_account_instant_verification_jwt.jwt).to eq("test-jwt-token")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "returns error result with validation errors" do
|
|
42
|
+
mock_response = {
|
|
43
|
+
:errors => [
|
|
44
|
+
{
|
|
45
|
+
:message => "Validation error",
|
|
46
|
+
:extensions => {}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
allow(graphql_client).to receive(:query).and_return(mock_response)
|
|
52
|
+
|
|
53
|
+
result = bank_account_instant_verification_gateway.create_jwt(request)
|
|
54
|
+
|
|
55
|
+
expect(result.success?).to eq(false)
|
|
56
|
+
expect(result.errors).not_to be_nil
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "calls GraphQL client with correct mutation" do
|
|
60
|
+
mock_response = {
|
|
61
|
+
:data => {
|
|
62
|
+
:createBankAccountInstantVerificationJwt => {
|
|
63
|
+
:jwt => "test-jwt-token"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
expect(graphql_client).to receive(:query).with(
|
|
69
|
+
/mutation CreateBankAccountInstantVerificationJwt/,
|
|
70
|
+
{:input=>{:businessName=>"Test Business", :cancelUrl=>"https://example.com/cancel", :returnUrl=>"https://example.com/success"}},
|
|
71
|
+
).and_return(mock_response)
|
|
72
|
+
|
|
73
|
+
bank_account_instant_verification_gateway.create_jwt(request)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "works with minimal request" do
|
|
77
|
+
minimal_request = Braintree::BankAccountInstantVerificationJwtRequest.new(
|
|
78
|
+
:business_name => "Test Business",
|
|
79
|
+
:return_url => "https://example.com/success",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
mock_response = {
|
|
83
|
+
:data => {
|
|
84
|
+
:createBankAccountInstantVerificationJwt => {
|
|
85
|
+
:jwt => "test-jwt-token"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
allow(graphql_client).to receive(:query).and_return(mock_response)
|
|
91
|
+
|
|
92
|
+
result = bank_account_instant_verification_gateway.create_jwt(minimal_request)
|
|
93
|
+
|
|
94
|
+
expect(result.success?).to eq(true)
|
|
95
|
+
expect(result.bank_account_instant_verification_jwt.jwt).to eq("test-jwt-token")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|