braintree 4.14.0 → 4.15.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/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +3 -2
|
@@ -84,8 +84,8 @@ describe Braintree::MerchantAccount do
|
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
result = gateway.merchant_account.all
|
|
87
|
-
result.
|
|
88
|
-
result.merchant_accounts.count.
|
|
87
|
+
expect(result).to be_success
|
|
88
|
+
expect(result.merchant_accounts.count).to be > 20
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it "returns merchant account with correct attributes" do
|
|
@@ -107,11 +107,11 @@ describe Braintree::MerchantAccount do
|
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
result = gateway.merchant_account.all
|
|
110
|
-
result.
|
|
111
|
-
result.merchant_accounts.count.
|
|
112
|
-
result.merchant_accounts.first.currency_iso_code.
|
|
113
|
-
result.merchant_accounts.first.status.
|
|
114
|
-
result.merchant_accounts.first.default.
|
|
110
|
+
expect(result).to be_success
|
|
111
|
+
expect(result.merchant_accounts.count).to eq(1)
|
|
112
|
+
expect(result.merchant_accounts.first.currency_iso_code).to eq("USD")
|
|
113
|
+
expect(result.merchant_accounts.first.status).to eq("active")
|
|
114
|
+
expect(result.merchant_accounts.first.default).to eq(true)
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
it "returns all merchant accounts for read_only scoped grants" do
|
|
@@ -137,8 +137,8 @@ describe Braintree::MerchantAccount do
|
|
|
137
137
|
)
|
|
138
138
|
|
|
139
139
|
result = gateway.merchant_account.all
|
|
140
|
-
result.
|
|
141
|
-
result.merchant_accounts.count.
|
|
140
|
+
expect(result).to be_success
|
|
141
|
+
expect(result.merchant_accounts.count).to be > 20
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
@@ -146,17 +146,17 @@ describe Braintree::MerchantAccount do
|
|
|
146
146
|
it "accepts the deprecated parameters" do
|
|
147
147
|
result = Braintree::MerchantAccount.create(DEPRECATED_APPLICATION_PARAMS)
|
|
148
148
|
|
|
149
|
-
result.
|
|
150
|
-
result.merchant_account.status.
|
|
151
|
-
result.merchant_account.master_merchant_account.id.
|
|
149
|
+
expect(result).to be_success
|
|
150
|
+
expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
|
|
151
|
+
expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "creates a merchant account with the new parameters and doesn't require an id" do
|
|
155
155
|
result = Braintree::MerchantAccount.create(VALID_APPLICATION_PARAMS)
|
|
156
156
|
|
|
157
|
-
result.
|
|
158
|
-
result.merchant_account.status.
|
|
159
|
-
result.merchant_account.master_merchant_account.id.
|
|
157
|
+
expect(result).to be_success
|
|
158
|
+
expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
|
|
159
|
+
expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
it "allows an id to be passed" do
|
|
@@ -168,24 +168,24 @@ describe Braintree::MerchantAccount do
|
|
|
168
168
|
),
|
|
169
169
|
)
|
|
170
170
|
|
|
171
|
-
result.
|
|
172
|
-
result.merchant_account.status.
|
|
173
|
-
result.merchant_account.id.
|
|
174
|
-
result.merchant_account.master_merchant_account.id.
|
|
171
|
+
expect(result).to be_success
|
|
172
|
+
expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
|
|
173
|
+
expect(result.merchant_account.id).to eq(sub_merchant_account_id)
|
|
174
|
+
expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
it "handles unsuccessful results" do
|
|
178
178
|
result = Braintree::MerchantAccount.create({})
|
|
179
|
-
result.
|
|
180
|
-
result.errors.for(:merchant_account).on(:master_merchant_account_id).first.code.
|
|
179
|
+
expect(result).not_to be_success
|
|
180
|
+
expect(result.errors.for(:merchant_account).on(:master_merchant_account_id).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::MasterMerchantAccountIdIsRequired)
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
it "requires all fields" do
|
|
184
184
|
result = Braintree::MerchantAccount.create(
|
|
185
185
|
:master_merchant_account_id => "sandbox_master_merchant_account",
|
|
186
186
|
)
|
|
187
|
-
result.
|
|
188
|
-
result.errors.for(:merchant_account).on(:tos_accepted).first.code.
|
|
187
|
+
expect(result).not_to be_success
|
|
188
|
+
expect(result.errors.for(:merchant_account).on(:tos_accepted).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::TosAcceptedIsRequired)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
context "funding destination" do
|
|
@@ -194,7 +194,7 @@ describe Braintree::MerchantAccount do
|
|
|
194
194
|
params[:funding][:destination] = ::Braintree::MerchantAccount::FundingDestination::Bank
|
|
195
195
|
result = Braintree::MerchantAccount.create(params)
|
|
196
196
|
|
|
197
|
-
result.
|
|
197
|
+
expect(result).to be_success
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
it "accepts an email" do
|
|
@@ -203,7 +203,7 @@ describe Braintree::MerchantAccount do
|
|
|
203
203
|
params[:funding][:email] = "joebloggs@compuserve.com"
|
|
204
204
|
result = Braintree::MerchantAccount.create(params)
|
|
205
205
|
|
|
206
|
-
result.
|
|
206
|
+
expect(result).to be_success
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
it "accepts a mobile_phone" do
|
|
@@ -212,7 +212,7 @@ describe Braintree::MerchantAccount do
|
|
|
212
212
|
params[:funding][:mobile_phone] = "3125882300"
|
|
213
213
|
result = Braintree::MerchantAccount.create(params)
|
|
214
214
|
|
|
215
|
-
result.
|
|
215
|
+
expect(result).to be_success
|
|
216
216
|
end
|
|
217
217
|
end
|
|
218
218
|
end
|
|
@@ -221,15 +221,15 @@ describe Braintree::MerchantAccount do
|
|
|
221
221
|
it "creates a merchant account with the new parameters and doesn't require an id" do
|
|
222
222
|
merchant_account = Braintree::MerchantAccount.create!(VALID_APPLICATION_PARAMS)
|
|
223
223
|
|
|
224
|
-
merchant_account.status.
|
|
225
|
-
merchant_account.master_merchant_account.id.
|
|
224
|
+
expect(merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
|
|
225
|
+
expect(merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
|
|
226
226
|
end
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
describe "create_for_currency" do
|
|
230
230
|
it "creates a new merchant account for currency" do
|
|
231
231
|
result = SpecHelper::create_merchant
|
|
232
|
-
result.
|
|
232
|
+
expect(result).to be_success
|
|
233
233
|
|
|
234
234
|
gateway = Braintree::Gateway.new(
|
|
235
235
|
:access_token => result.credentials.access_token,
|
|
@@ -239,13 +239,13 @@ describe Braintree::MerchantAccount do
|
|
|
239
239
|
result = gateway.merchant_account.create_for_currency(
|
|
240
240
|
:currency => "JPY",
|
|
241
241
|
)
|
|
242
|
-
result.
|
|
243
|
-
result.merchant_account.currency_iso_code.
|
|
242
|
+
expect(result).to be_success
|
|
243
|
+
expect(result.merchant_account.currency_iso_code).to eq("JPY")
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
it "returns error if a merchant account already exists for that currency" do
|
|
247
247
|
result = SpecHelper::create_merchant
|
|
248
|
-
result.
|
|
248
|
+
expect(result).to be_success
|
|
249
249
|
|
|
250
250
|
gateway = Braintree::Gateway.new(
|
|
251
251
|
:access_token => result.credentials.access_token,
|
|
@@ -255,20 +255,20 @@ describe Braintree::MerchantAccount do
|
|
|
255
255
|
result = gateway.merchant_account.create_for_currency(
|
|
256
256
|
:currency => "USD",
|
|
257
257
|
)
|
|
258
|
-
result.
|
|
258
|
+
expect(result).to be_success
|
|
259
259
|
|
|
260
260
|
result = gateway.merchant_account.create_for_currency(
|
|
261
261
|
:currency => "USD",
|
|
262
262
|
)
|
|
263
|
-
result.
|
|
263
|
+
expect(result).not_to be_success
|
|
264
264
|
|
|
265
265
|
errors = result.errors.for(:merchant).on(:currency)
|
|
266
|
-
errors[0].code.
|
|
266
|
+
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::MerchantAccountExistsForCurrency)
|
|
267
267
|
end
|
|
268
268
|
|
|
269
269
|
it "returns error if no currency is provided" do
|
|
270
270
|
result = SpecHelper::create_merchant
|
|
271
|
-
result.
|
|
271
|
+
expect(result).to be_success
|
|
272
272
|
|
|
273
273
|
gateway = Braintree::Gateway.new(
|
|
274
274
|
:access_token => result.credentials.access_token,
|
|
@@ -278,21 +278,21 @@ describe Braintree::MerchantAccount do
|
|
|
278
278
|
result = gateway.merchant_account.create_for_currency(
|
|
279
279
|
:currency => nil,
|
|
280
280
|
)
|
|
281
|
-
result.
|
|
281
|
+
expect(result).not_to be_success
|
|
282
282
|
|
|
283
283
|
errors = result.errors.for(:merchant).on(:currency)
|
|
284
|
-
errors[0].code.
|
|
284
|
+
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::CurrencyIsRequired)
|
|
285
285
|
|
|
286
286
|
result = gateway.merchant_account.create_for_currency({})
|
|
287
|
-
result.
|
|
287
|
+
expect(result).not_to be_success
|
|
288
288
|
|
|
289
289
|
errors = result.errors.for(:merchant).on(:currency)
|
|
290
|
-
errors[0].code.
|
|
290
|
+
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::CurrencyIsRequired)
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
it "returns error if a currency is not supported" do
|
|
294
294
|
result = SpecHelper::create_merchant
|
|
295
|
-
result.
|
|
295
|
+
expect(result).to be_success
|
|
296
296
|
|
|
297
297
|
gateway = Braintree::Gateway.new(
|
|
298
298
|
:access_token => result.credentials.access_token,
|
|
@@ -302,15 +302,15 @@ describe Braintree::MerchantAccount do
|
|
|
302
302
|
result = gateway.merchant_account.create_for_currency(
|
|
303
303
|
:currency => "FAKE_CURRENCY",
|
|
304
304
|
)
|
|
305
|
-
result.
|
|
305
|
+
expect(result).not_to be_success
|
|
306
306
|
|
|
307
307
|
errors = result.errors.for(:merchant).on(:currency)
|
|
308
|
-
errors[0].code.
|
|
308
|
+
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::CurrencyIsInvalid)
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
it "returns error if id is passed and already taken" do
|
|
312
312
|
result = SpecHelper::create_merchant
|
|
313
|
-
result.
|
|
313
|
+
expect(result).to be_success
|
|
314
314
|
|
|
315
315
|
gateway = Braintree::Gateway.new(
|
|
316
316
|
:access_token => result.credentials.access_token,
|
|
@@ -322,30 +322,30 @@ describe Braintree::MerchantAccount do
|
|
|
322
322
|
:currency => "USD",
|
|
323
323
|
:id => merchant.merchant_accounts.first.id,
|
|
324
324
|
)
|
|
325
|
-
result.
|
|
325
|
+
expect(result).not_to be_success
|
|
326
326
|
|
|
327
327
|
errors = result.errors.for(:merchant).on(:id)
|
|
328
|
-
errors[0].code.
|
|
328
|
+
expect(errors[0].code).to eq(Braintree::ErrorCodes::Merchant::MerchantAccountExistsForId)
|
|
329
329
|
end
|
|
330
330
|
end
|
|
331
331
|
|
|
332
332
|
describe "find" do
|
|
333
333
|
it "finds the merchant account with the given token" do
|
|
334
334
|
result = Braintree::MerchantAccount.create(VALID_APPLICATION_PARAMS)
|
|
335
|
-
result.
|
|
336
|
-
result.merchant_account.status.
|
|
335
|
+
expect(result).to be_success
|
|
336
|
+
expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
|
|
337
337
|
|
|
338
338
|
id = result.merchant_account.id
|
|
339
339
|
merchant_account = Braintree::MerchantAccount.find(id)
|
|
340
340
|
|
|
341
|
-
merchant_account.individual_details.first_name.
|
|
342
|
-
merchant_account.individual_details.last_name.
|
|
341
|
+
expect(merchant_account.individual_details.first_name).to eq(VALID_APPLICATION_PARAMS[:individual][:first_name])
|
|
342
|
+
expect(merchant_account.individual_details.last_name).to eq(VALID_APPLICATION_PARAMS[:individual][:last_name])
|
|
343
343
|
end
|
|
344
344
|
|
|
345
345
|
it "retrieves the currency iso code for an existing master merchant account" do
|
|
346
346
|
merchant_account = Braintree::MerchantAccount.find("sandbox_master_merchant_account")
|
|
347
347
|
|
|
348
|
-
merchant_account.currency_iso_code.
|
|
348
|
+
expect(merchant_account.currency_iso_code).to eq("USD")
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
it "raises a NotFoundError exception if merchant account cannot be found" do
|
|
@@ -382,37 +382,37 @@ describe Braintree::MerchantAccount do
|
|
|
382
382
|
params[:funding][:mobile_phone] = "1234567890"
|
|
383
383
|
params[:funding][:destination] = Braintree::MerchantAccount::FundingDestination::MobilePhone
|
|
384
384
|
result = Braintree::MerchantAccount.update("sandbox_sub_merchant_account", params)
|
|
385
|
-
result.
|
|
386
|
-
result.merchant_account.status.
|
|
387
|
-
result.merchant_account.id.
|
|
388
|
-
result.merchant_account.master_merchant_account.id.
|
|
389
|
-
result.merchant_account.individual_details.first_name.
|
|
390
|
-
result.merchant_account.individual_details.last_name.
|
|
391
|
-
result.merchant_account.individual_details.email.
|
|
392
|
-
result.merchant_account.individual_details.date_of_birth.
|
|
393
|
-
result.merchant_account.individual_details.phone.
|
|
394
|
-
result.merchant_account.individual_details.address_details.street_address.
|
|
395
|
-
result.merchant_account.individual_details.address_details.locality.
|
|
396
|
-
result.merchant_account.individual_details.address_details.region.
|
|
397
|
-
result.merchant_account.individual_details.address_details.postal_code.
|
|
398
|
-
result.merchant_account.business_details.dba_name.
|
|
399
|
-
result.merchant_account.business_details.legal_name.
|
|
400
|
-
result.merchant_account.business_details.tax_id.
|
|
401
|
-
result.merchant_account.business_details.address_details.street_address.
|
|
402
|
-
result.merchant_account.business_details.address_details.locality.
|
|
403
|
-
result.merchant_account.business_details.address_details.region.
|
|
404
|
-
result.merchant_account.business_details.address_details.postal_code.
|
|
405
|
-
result.merchant_account.funding_details.account_number_last_4.
|
|
406
|
-
result.merchant_account.funding_details.routing_number.
|
|
407
|
-
result.merchant_account.funding_details.email.
|
|
408
|
-
result.merchant_account.funding_details.mobile_phone.
|
|
409
|
-
result.merchant_account.funding_details.destination.
|
|
410
|
-
result.merchant_account.funding_details.descriptor.
|
|
385
|
+
expect(result).to be_success
|
|
386
|
+
expect(result.merchant_account.status).to eq("active")
|
|
387
|
+
expect(result.merchant_account.id).to eq("sandbox_sub_merchant_account")
|
|
388
|
+
expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
|
|
389
|
+
expect(result.merchant_account.individual_details.first_name).to eq("John")
|
|
390
|
+
expect(result.merchant_account.individual_details.last_name).to eq("Doe")
|
|
391
|
+
expect(result.merchant_account.individual_details.email).to eq("john.doe@example.com")
|
|
392
|
+
expect(result.merchant_account.individual_details.date_of_birth).to eq("1970-01-01")
|
|
393
|
+
expect(result.merchant_account.individual_details.phone).to eq("3125551234")
|
|
394
|
+
expect(result.merchant_account.individual_details.address_details.street_address).to eq("123 Fake St")
|
|
395
|
+
expect(result.merchant_account.individual_details.address_details.locality).to eq("Chicago")
|
|
396
|
+
expect(result.merchant_account.individual_details.address_details.region).to eq("IL")
|
|
397
|
+
expect(result.merchant_account.individual_details.address_details.postal_code).to eq("60622")
|
|
398
|
+
expect(result.merchant_account.business_details.dba_name).to eq("James's Bloggs")
|
|
399
|
+
expect(result.merchant_account.business_details.legal_name).to eq("James's Bloggs Inc")
|
|
400
|
+
expect(result.merchant_account.business_details.tax_id).to eq("423456789")
|
|
401
|
+
expect(result.merchant_account.business_details.address_details.street_address).to eq("999 Fake St")
|
|
402
|
+
expect(result.merchant_account.business_details.address_details.locality).to eq("Miami")
|
|
403
|
+
expect(result.merchant_account.business_details.address_details.region).to eq("FL")
|
|
404
|
+
expect(result.merchant_account.business_details.address_details.postal_code).to eq("99999")
|
|
405
|
+
expect(result.merchant_account.funding_details.account_number_last_4).to eq("8798")
|
|
406
|
+
expect(result.merchant_account.funding_details.routing_number).to eq("071000013")
|
|
407
|
+
expect(result.merchant_account.funding_details.email).to eq("check@this.com")
|
|
408
|
+
expect(result.merchant_account.funding_details.mobile_phone).to eq("1234567890")
|
|
409
|
+
expect(result.merchant_account.funding_details.destination).to eq(Braintree::MerchantAccount::FundingDestination::MobilePhone)
|
|
410
|
+
expect(result.merchant_account.funding_details.descriptor).to eq("Joes Bloggs MI")
|
|
411
411
|
end
|
|
412
412
|
|
|
413
413
|
it "does not require all fields" do
|
|
414
414
|
result = Braintree::MerchantAccount.update("sandbox_sub_merchant_account", {:individual => {:first_name => "Jose"}})
|
|
415
|
-
result.
|
|
415
|
+
expect(result).to be_success
|
|
416
416
|
end
|
|
417
417
|
|
|
418
418
|
it "handles validation errors for blank fields" do
|
|
@@ -445,17 +445,17 @@ describe Braintree::MerchantAccount do
|
|
|
445
445
|
}
|
|
446
446
|
)
|
|
447
447
|
|
|
448
|
-
result.
|
|
449
|
-
result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code).
|
|
450
|
-
result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code).
|
|
451
|
-
result.errors.for(:merchant_account).for(:individual).on(:date_of_birth).map(&:code).
|
|
452
|
-
result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code).
|
|
453
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code).
|
|
454
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code).
|
|
455
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:locality).map(&:code).
|
|
456
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code).
|
|
457
|
-
result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code).
|
|
458
|
-
result.errors.for(:merchant_account).on(:base).
|
|
448
|
+
expect(result).not_to be_success
|
|
449
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::FirstNameIsRequired])
|
|
450
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::LastNameIsRequired])
|
|
451
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:date_of_birth).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::DateOfBirthIsRequired])
|
|
452
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::EmailIsRequired])
|
|
453
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::StreetAddressIsRequired])
|
|
454
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::PostalCodeIsRequired])
|
|
455
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:locality).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::LocalityIsRequired])
|
|
456
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::RegionIsRequired])
|
|
457
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::DestinationIsRequired])
|
|
458
|
+
expect(result.errors.for(:merchant_account).on(:base)).to be_empty
|
|
459
459
|
end
|
|
460
460
|
|
|
461
461
|
it "handles validation errors for invalid fields" do
|
|
@@ -494,30 +494,30 @@ describe Braintree::MerchantAccount do
|
|
|
494
494
|
}
|
|
495
495
|
)
|
|
496
496
|
|
|
497
|
-
result.
|
|
498
|
-
result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code).
|
|
499
|
-
result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code).
|
|
500
|
-
result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code).
|
|
501
|
-
result.errors.for(:merchant_account).for(:individual).on(:phone).map(&:code).
|
|
502
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code).
|
|
503
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code).
|
|
504
|
-
result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code).
|
|
505
|
-
result.errors.for(:merchant_account).for(:individual).on(:ssn).map(&:code).
|
|
506
|
-
|
|
507
|
-
result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code).
|
|
508
|
-
result.errors.for(:merchant_account).for(:business).on(:dba_name).map(&:code).
|
|
509
|
-
result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code).
|
|
510
|
-
result.errors.for(:merchant_account).for(:business).for(:address).on(:street_address).map(&:code).
|
|
511
|
-
result.errors.for(:merchant_account).for(:business).for(:address).on(:postal_code).map(&:code).
|
|
512
|
-
result.errors.for(:merchant_account).for(:business).for(:address).on(:region).map(&:code).
|
|
513
|
-
|
|
514
|
-
result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code).
|
|
515
|
-
result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code).
|
|
516
|
-
result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code).
|
|
517
|
-
result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code).
|
|
518
|
-
result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code).
|
|
519
|
-
|
|
520
|
-
result.errors.for(:merchant_account).on(:base).
|
|
497
|
+
expect(result).not_to be_success
|
|
498
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::FirstNameIsInvalid])
|
|
499
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::LastNameIsInvalid])
|
|
500
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::EmailIsInvalid])
|
|
501
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::PhoneIsInvalid])
|
|
502
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::StreetAddressIsInvalid])
|
|
503
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::PostalCodeIsInvalid])
|
|
504
|
+
expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::RegionIsInvalid])
|
|
505
|
+
expect(result.errors.for(:merchant_account).for(:individual).on(:ssn).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::SsnIsInvalid])
|
|
506
|
+
|
|
507
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::LegalNameIsInvalid])
|
|
508
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:dba_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::DbaNameIsInvalid])
|
|
509
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdIsInvalid])
|
|
510
|
+
expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::StreetAddressIsInvalid])
|
|
511
|
+
expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::PostalCodeIsInvalid])
|
|
512
|
+
expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::RegionIsInvalid])
|
|
513
|
+
|
|
514
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::DestinationIsInvalid])
|
|
515
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::RoutingNumberIsInvalid])
|
|
516
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::AccountNumberIsInvalid])
|
|
517
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::EmailIsInvalid])
|
|
518
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::MobilePhoneIsInvalid])
|
|
519
|
+
|
|
520
|
+
expect(result.errors.for(:merchant_account).on(:base)).to be_empty
|
|
521
521
|
end
|
|
522
522
|
|
|
523
523
|
it "handles validation errors for business fields" do
|
|
@@ -530,9 +530,9 @@ describe Braintree::MerchantAccount do
|
|
|
530
530
|
}
|
|
531
531
|
)
|
|
532
532
|
|
|
533
|
-
result.
|
|
534
|
-
result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code).
|
|
535
|
-
result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code).
|
|
533
|
+
expect(result).not_to be_success
|
|
534
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::LegalNameIsRequiredWithTaxId])
|
|
535
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdMustBeBlank])
|
|
536
536
|
|
|
537
537
|
result = Braintree::MerchantAccount.update(
|
|
538
538
|
"sandbox_sub_merchant_account", {
|
|
@@ -543,8 +543,8 @@ describe Braintree::MerchantAccount do
|
|
|
543
543
|
}
|
|
544
544
|
)
|
|
545
545
|
|
|
546
|
-
result.
|
|
547
|
-
result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code).
|
|
546
|
+
expect(result).not_to be_success
|
|
547
|
+
expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdIsRequiredWithLegalName])
|
|
548
548
|
end
|
|
549
549
|
|
|
550
550
|
it "handles validation errors for funding fields" do
|
|
@@ -558,9 +558,9 @@ describe Braintree::MerchantAccount do
|
|
|
558
558
|
}
|
|
559
559
|
)
|
|
560
560
|
|
|
561
|
-
result.
|
|
562
|
-
result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code).
|
|
563
|
-
result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code).
|
|
561
|
+
expect(result).not_to be_success
|
|
562
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::RoutingNumberIsRequired])
|
|
563
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::AccountNumberIsRequired])
|
|
564
564
|
|
|
565
565
|
result = Braintree::MerchantAccount.update(
|
|
566
566
|
"sandbox_sub_merchant_account", {
|
|
@@ -571,8 +571,8 @@ describe Braintree::MerchantAccount do
|
|
|
571
571
|
}
|
|
572
572
|
)
|
|
573
573
|
|
|
574
|
-
result.
|
|
575
|
-
result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code).
|
|
574
|
+
expect(result).not_to be_success
|
|
575
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::EmailIsRequired])
|
|
576
576
|
|
|
577
577
|
result = Braintree::MerchantAccount.update(
|
|
578
578
|
"sandbox_sub_merchant_account", {
|
|
@@ -583,8 +583,8 @@ describe Braintree::MerchantAccount do
|
|
|
583
583
|
}
|
|
584
584
|
)
|
|
585
585
|
|
|
586
|
-
result.
|
|
587
|
-
result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code).
|
|
586
|
+
expect(result).not_to be_success
|
|
587
|
+
expect(result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::MobilePhoneIsRequired])
|
|
588
588
|
end
|
|
589
589
|
end
|
|
590
590
|
|
|
@@ -596,8 +596,8 @@ describe Braintree::MerchantAccount do
|
|
|
596
596
|
params[:individual][:first_name] = "John"
|
|
597
597
|
params[:individual][:last_name] = "Doe"
|
|
598
598
|
merchant_account = Braintree::MerchantAccount.update!("sandbox_sub_merchant_account", params)
|
|
599
|
-
merchant_account.individual_details.first_name.
|
|
600
|
-
merchant_account.individual_details.last_name.
|
|
599
|
+
expect(merchant_account.individual_details.first_name).to eq("John")
|
|
600
|
+
expect(merchant_account.individual_details.last_name).to eq("Doe")
|
|
601
601
|
end
|
|
602
602
|
end
|
|
603
603
|
end
|