braintree 4.29.0 → 4.31.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/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +2 -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 +1 -0
- data/lib/braintree/transaction.rb +3 -0
- data/lib/braintree/transaction_gateway.rb +29 -0
- data/lib/braintree/us_bank_account_verification.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +16 -0
- 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/dispute_spec.rb +13 -2
- data/spec/integration/braintree/payment_method_spec.rb +3 -0
- data/spec/integration/braintree/transaction_search_spec.rb +26 -24
- data/spec/integration/braintree/transaction_spec.rb +43 -3
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +301 -0
- 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/dispute_spec.rb +6 -0
- data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +25 -0
- data/spec/unit/braintree/transaction_spec.rb +18 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +17 -0
- metadata +11 -4
- 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")
|
@@ -7755,4 +7786,13 @@ describe Braintree::Transaction do
|
|
7755
7786
|
expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
7756
7787
|
end
|
7757
7788
|
end
|
7789
|
+
|
7790
|
+
describe "upcoming_retry_date" do
|
7791
|
+
it "returns the upcoming retry date for ACH transactions" do
|
7792
|
+
transaction = Braintree::Transaction.find("first_attempted_ach_transaction")
|
7793
|
+
|
7794
|
+
tomorrow = Date.today + 1
|
7795
|
+
expect(transaction.upcoming_retry_date).to eq(tomorrow.to_s)
|
7796
|
+
end
|
7797
|
+
end
|
7758
7798
|
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
|
4
|
+
describe Braintree::Transaction do
|
5
|
+
describe "self.transfer type" do
|
6
|
+
it "should create a transaction with valid transfer types and merchant account id" do
|
7
|
+
transaction_params = {
|
8
|
+
:type => "sale",
|
9
|
+
:amount => "100.00",
|
10
|
+
:merchant_account_id => "aft_first_data_wallet_transfer",
|
11
|
+
:credit_card => {
|
12
|
+
:number => "4111111111111111",
|
13
|
+
:expiration_date => "06/2026",
|
14
|
+
:cvv => "123"
|
15
|
+
},
|
16
|
+
:transfer => {
|
17
|
+
:type => "wallet_transfer",
|
18
|
+
},
|
19
|
+
}
|
20
|
+
|
21
|
+
result = Braintree::Transaction.sale(transaction_params)
|
22
|
+
expect(result.success?).to eq(true)
|
23
|
+
expect(result.transaction.account_funding_transaction).to eq(true)
|
24
|
+
expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should fail on transaction with non brazil merchant" do
|
28
|
+
transaction_params = {
|
29
|
+
:type => "sale",
|
30
|
+
:amount => "100.00",
|
31
|
+
:merchant_account_id => "aft_first_data_wallet_transfer",
|
32
|
+
:credit_card => {
|
33
|
+
:number => "4111111111111111",
|
34
|
+
:expiration_date => "06/2026",
|
35
|
+
:cvv => "123"
|
36
|
+
},
|
37
|
+
:transfer => {
|
38
|
+
:type => "invalid_transfer",
|
39
|
+
},
|
40
|
+
}
|
41
|
+
|
42
|
+
result = Braintree::Transaction.sale(transaction_params)
|
43
|
+
expect(result.success?).to eq(false)
|
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
|
300
|
+
end
|
301
|
+
end
|
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
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::BankAccountInstantVerificationJwtRequest do
|
4
|
+
describe "to_graphql_variables" do
|
5
|
+
it "includes all fields when present" do
|
6
|
+
request = Braintree::BankAccountInstantVerificationJwtRequest.new(
|
7
|
+
:business_name => "Test Business",
|
8
|
+
:return_url => "https://example.com/success",
|
9
|
+
:cancel_url => "https://example.com/cancel",
|
10
|
+
)
|
11
|
+
|
12
|
+
variables = request.to_graphql_variables
|
13
|
+
|
14
|
+
expect(variables).not_to be_nil
|
15
|
+
expect(variables).to have_key(:input)
|
16
|
+
|
17
|
+
input = variables[:input]
|
18
|
+
|
19
|
+
expect(input[:businessName]).to eq("Test Business")
|
20
|
+
expect(input[:returnUrl]).to eq("https://example.com/success")
|
21
|
+
expect(input[:cancelUrl]).to eq("https://example.com/cancel")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "only includes non-null fields" do
|
25
|
+
request = Braintree::BankAccountInstantVerificationJwtRequest.new(
|
26
|
+
:business_name => "Test Business",
|
27
|
+
:return_url => "https://example.com/success",
|
28
|
+
)
|
29
|
+
|
30
|
+
variables = request.to_graphql_variables
|
31
|
+
|
32
|
+
input = variables[:input]
|
33
|
+
|
34
|
+
expect(input[:businessName]).to eq("Test Business")
|
35
|
+
expect(input[:returnUrl]).to eq("https://example.com/success")
|
36
|
+
expect(input).not_to have_key(:cancelUrl)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "handles empty request" do
|
40
|
+
request = Braintree::BankAccountInstantVerificationJwtRequest.new
|
41
|
+
|
42
|
+
variables = request.to_graphql_variables
|
43
|
+
|
44
|
+
expect(variables).to eq({:input => {}})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "attribute accessors" do
|
49
|
+
it "allows setting and getting all attributes and initializes with hash of attributes" do
|
50
|
+
request = Braintree::BankAccountInstantVerificationJwtRequest.new(
|
51
|
+
:business_name => "Test Business",
|
52
|
+
:return_url => "https://example.com/success",
|
53
|
+
:cancel_url => "https://example.com/cancel",
|
54
|
+
)
|
55
|
+
|
56
|
+
expect(request.business_name).to eq("Test Business")
|
57
|
+
expect(request.return_url).to eq("https://example.com/success")
|
58
|
+
expect(request.cancel_url).to eq("https://example.com/cancel")
|
59
|
+
|
60
|
+
new_request = Braintree::BankAccountInstantVerificationJwtRequest.new
|
61
|
+
|
62
|
+
new_request.business_name = "Updated Business"
|
63
|
+
new_request.return_url = "https://example.com/updated"
|
64
|
+
new_request.cancel_url = "https://example.com/updated-cancel"
|
65
|
+
|
66
|
+
expect(new_request.business_name).to eq("Updated Business")
|
67
|
+
expect(new_request.return_url).to eq("https://example.com/updated")
|
68
|
+
expect(new_request.cancel_url).to eq("https://example.com/updated-cancel")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -40,6 +40,7 @@ describe Braintree::Dispute do
|
|
40
40
|
:timestamp => Time.utc(2009, 3, 9, 10, 50, 39),
|
41
41
|
}
|
42
42
|
],
|
43
|
+
:remaining_file_evidence_storage => 341029,
|
43
44
|
:transaction => {
|
44
45
|
:amount => "31.00",
|
45
46
|
:id => "open_disputed_transaction",
|
@@ -436,6 +437,11 @@ describe Braintree::Dispute do
|
|
436
437
|
|
437
438
|
expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
438
439
|
end
|
440
|
+
|
441
|
+
it "checks that the remaining_file_evidence_storage field is set correctly" do
|
442
|
+
dispute = Braintree::Dispute._new(attributes)
|
443
|
+
dispute.remaining_file_evidence_storage.should == 341029
|
444
|
+
end
|
439
445
|
end
|
440
446
|
|
441
447
|
describe "==" do
|