braintree 3.1.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/braintree.gemspec +3 -3
- data/lib/braintree.rb +8 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +14 -4
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +6 -4
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +15 -1
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +3 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +12 -4
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +11 -8
- data/lib/braintree/payment_method_nonce.rb +1 -1
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +40 -24
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction_gateway.rb +27 -6
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +30 -20
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +30 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +0 -1
- data/lib/braintree/xml/parser.rb +22 -12
- data/lib/braintree/xml/rexml.rb +70 -0
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +28 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +213 -122
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +433 -149
- data/spec/integration/braintree/dispute_search_spec.rb +28 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +26 -35
- data/spec/integration/braintree/payment_method_spec.rb +430 -149
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +752 -383
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +9 -3
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +13 -13
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +21 -10
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +34 -9
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- 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/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +18 -8
- data/lib/braintree/settlement_batch.rb +0 -0
@@ -24,7 +24,7 @@ describe Braintree::Transaction do
|
|
24
24
|
:country_code_alpha2 => "BT",
|
25
25
|
:country_code_alpha3 => "BTN",
|
26
26
|
:country_code_numeric => "064"
|
27
|
-
}
|
27
|
+
},
|
28
28
|
)
|
29
29
|
result.success?.should == true
|
30
30
|
|
@@ -34,7 +34,7 @@ describe Braintree::Transaction do
|
|
34
34
|
:channel => "MyShoppingCartProvider",
|
35
35
|
:options => {
|
36
36
|
:submit_for_settlement => false
|
37
|
-
}
|
37
|
+
},
|
38
38
|
)
|
39
39
|
clone_result.success?.should == true
|
40
40
|
|
@@ -67,7 +67,7 @@ describe Braintree::Transaction do
|
|
67
67
|
:credit_card => {
|
68
68
|
:number => "5105105105105100",
|
69
69
|
:expiration_date => "05/2012"
|
70
|
-
}
|
70
|
+
},
|
71
71
|
)
|
72
72
|
|
73
73
|
result.success?.should be(true)
|
@@ -84,7 +84,7 @@ describe Braintree::Transaction do
|
|
84
84
|
:credit_card => {
|
85
85
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
86
86
|
:expiration_date => "05/2009"
|
87
|
-
}
|
87
|
+
},
|
88
88
|
)
|
89
89
|
result = Braintree::Transaction.clone_transaction(transaction.id, :amount => "112.44")
|
90
90
|
result.success?.should be(false)
|
@@ -100,7 +100,7 @@ describe Braintree::Transaction do
|
|
100
100
|
:credit_card => {
|
101
101
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
102
102
|
:expiration_date => "05/2009"
|
103
|
-
}
|
103
|
+
},
|
104
104
|
)
|
105
105
|
clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "112.44", :options => {:submit_for_settlement => false})
|
106
106
|
clone_transaction.id.should_not == transaction.id
|
@@ -112,7 +112,7 @@ describe Braintree::Transaction do
|
|
112
112
|
:credit_card => {
|
113
113
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
114
114
|
:expiration_date => "05/2009"
|
115
|
-
}
|
115
|
+
},
|
116
116
|
)
|
117
117
|
expect do
|
118
118
|
clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "im not a number")
|
@@ -123,26 +123,28 @@ describe Braintree::Transaction do
|
|
123
123
|
|
124
124
|
describe "self.create" do
|
125
125
|
describe "risk data" do
|
126
|
-
it "returns decision, device_data_captured and
|
127
|
-
|
126
|
+
it "returns decision, device_data_captured, id, transaction_risk_score, and decision_reasons" do
|
127
|
+
with_fraud_protection_enterprise_merchant do
|
128
128
|
result = Braintree::Transaction.create(
|
129
129
|
:type => "sale",
|
130
130
|
:amount => 1_00,
|
131
131
|
:credit_card => {
|
132
132
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
133
133
|
:expiration_date => "05/2009"
|
134
|
-
}
|
134
|
+
},
|
135
135
|
)
|
136
136
|
result.transaction.risk_data.should be_a(Braintree::RiskData)
|
137
|
-
result.transaction.risk_data.
|
138
|
-
result.transaction.risk_data.
|
139
|
-
result.transaction.risk_data.
|
140
|
-
result.transaction.risk_data.
|
137
|
+
result.transaction.risk_data.id.should_not be_nil
|
138
|
+
result.transaction.risk_data.decision.should_not be_nil
|
139
|
+
result.transaction.risk_data.decision_reasons.should_not be_nil
|
140
|
+
expect(result.transaction.risk_data).to respond_to(:device_data_captured)
|
141
|
+
expect(result.transaction.risk_data).to respond_to(:fraud_service_provider)
|
142
|
+
expect(result.transaction.risk_data).to respond_to(:transaction_risk_score)
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
144
146
|
it "handles validation errors for invalid risk data attributes" do
|
145
|
-
|
147
|
+
with_advanced_fraud_kount_integration_merchant do
|
146
148
|
result = Braintree::Transaction.create(
|
147
149
|
:type => "sale",
|
148
150
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -156,10 +158,9 @@ describe Braintree::Transaction do
|
|
156
158
|
:customer_ip => "192.168.0.1",
|
157
159
|
:customer_location_zip => "not-a-$#phone",
|
158
160
|
:customer_tenure => "20#{"0" * 500}"
|
159
|
-
}
|
161
|
+
},
|
160
162
|
)
|
161
163
|
result.success?.should == false
|
162
|
-
result.errors.for(:transaction).for(:risk_data).on(:customer_browser).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerBrowserIsTooLong
|
163
164
|
result.errors.for(:transaction).for(:risk_data).on(:customer_device_id).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerDeviceIdIsTooLong
|
164
165
|
result.errors.for(:transaction).for(:risk_data).on(:customer_location_zip).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerLocationZipInvalidCharacters
|
165
166
|
result.errors.for(:transaction).for(:risk_data).on(:customer_tenure).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerTenureIsTooLong
|
@@ -175,13 +176,49 @@ describe Braintree::Transaction do
|
|
175
176
|
:credit_card => {
|
176
177
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
177
178
|
:expiration_date => "05/2009"
|
178
|
-
}
|
179
|
+
},
|
179
180
|
)
|
180
181
|
result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
181
182
|
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::CreditCard
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
186
|
+
describe "sca_exemption" do
|
187
|
+
context "with a valid request" do
|
188
|
+
it "succeeds" do
|
189
|
+
requested_exemption = "low_value"
|
190
|
+
result = Braintree::Transaction.create(
|
191
|
+
:type => "sale",
|
192
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
193
|
+
:credit_card => {
|
194
|
+
:number => Braintree::Test::CreditCardNumbers::VisaCountryOfIssuanceIE,
|
195
|
+
:expiration_date => "05/2009"
|
196
|
+
},
|
197
|
+
:sca_exemption => requested_exemption,
|
198
|
+
)
|
199
|
+
expect(result).to be_success
|
200
|
+
expect(result.transaction.sca_exemption_requested).to eq(requested_exemption)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context "with an invalid request" do
|
205
|
+
it "returns an error" do
|
206
|
+
result = Braintree::Transaction.create(
|
207
|
+
:type => "sale",
|
208
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
209
|
+
:credit_card => {
|
210
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
211
|
+
:expiration_date => "05/2009"
|
212
|
+
},
|
213
|
+
:sca_exemption => "invalid_sca_exemption_value",
|
214
|
+
)
|
215
|
+
sca_exemption_invalid = Braintree::ErrorCodes::Transaction::ScaExemptionInvalid
|
216
|
+
expect(result).not_to be_success
|
217
|
+
expect(result.errors.for(:transaction).map(&:code)).to eq([sca_exemption_invalid])
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
185
222
|
describe "industry data" do
|
186
223
|
context "for lodging" do
|
187
224
|
it "accepts valid industry data" do
|
@@ -215,7 +252,7 @@ describe Braintree::Transaction do
|
|
215
252
|
},
|
216
253
|
],
|
217
254
|
}
|
218
|
-
}
|
255
|
+
},
|
219
256
|
)
|
220
257
|
result.success?.should be(true)
|
221
258
|
end
|
@@ -242,15 +279,15 @@ describe Braintree::Transaction do
|
|
242
279
|
},
|
243
280
|
],
|
244
281
|
}
|
245
|
-
}
|
282
|
+
},
|
246
283
|
)
|
247
284
|
result.success?.should be(false)
|
248
285
|
invalid_folio = Braintree::ErrorCodes::Transaction::Industry::Lodging::FolioNumberIsInvalid
|
249
286
|
check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate
|
250
287
|
room_rate_format_is_invalid = Braintree::ErrorCodes::Transaction::Industry::Lodging::RoomRateFormatIsInvalid
|
251
288
|
invalid_additional_charge_kind = Braintree::ErrorCodes::Transaction::Industry::AdditionalCharge::KindIsInvalid
|
252
|
-
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include
|
253
|
-
result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include
|
289
|
+
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include(*[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid])
|
290
|
+
result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include(*[invalid_additional_charge_kind])
|
254
291
|
end
|
255
292
|
end
|
256
293
|
|
@@ -272,7 +309,7 @@ describe Braintree::Transaction do
|
|
272
309
|
:lodging_check_out_date => "2014-07-07",
|
273
310
|
:lodging_name => "Royal Caribbean",
|
274
311
|
}
|
275
|
-
}
|
312
|
+
},
|
276
313
|
)
|
277
314
|
result.success?.should be(true)
|
278
315
|
end
|
@@ -290,7 +327,7 @@ describe Braintree::Transaction do
|
|
290
327
|
:data => {
|
291
328
|
:lodging_name => "Royal Caribbean"
|
292
329
|
}
|
293
|
-
}
|
330
|
+
},
|
294
331
|
)
|
295
332
|
result.success?.should be(false)
|
296
333
|
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelCruise::TravelPackageIsInvalid]
|
@@ -364,7 +401,7 @@ describe Braintree::Transaction do
|
|
364
401
|
}
|
365
402
|
]
|
366
403
|
}
|
367
|
-
}
|
404
|
+
},
|
368
405
|
)
|
369
406
|
result.success?.should be(true)
|
370
407
|
end
|
@@ -388,7 +425,7 @@ describe Braintree::Transaction do
|
|
388
425
|
}
|
389
426
|
]
|
390
427
|
}
|
391
|
-
}
|
428
|
+
},
|
392
429
|
)
|
393
430
|
result.success?.should be(false)
|
394
431
|
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative]
|
@@ -407,7 +444,7 @@ describe Braintree::Transaction do
|
|
407
444
|
:number => Braintree::Test::CreditCardNumbers::Elo,
|
408
445
|
:cvv => "737",
|
409
446
|
:expiration_date => "10/2020"
|
410
|
-
}
|
447
|
+
},
|
411
448
|
)
|
412
449
|
result.success?.should == true
|
413
450
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -429,7 +466,7 @@ describe Braintree::Transaction do
|
|
429
466
|
:credit_card => {
|
430
467
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
431
468
|
:expiration_date => "05/2009"
|
432
|
-
}
|
469
|
+
},
|
433
470
|
)
|
434
471
|
result.success?.should == true
|
435
472
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -455,7 +492,7 @@ describe Braintree::Transaction do
|
|
455
492
|
:credit_card => {
|
456
493
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
457
494
|
:expiration_date => "05/2009"
|
458
|
-
}
|
495
|
+
},
|
459
496
|
)
|
460
497
|
expect(result.success?).to eq(true)
|
461
498
|
expect(result.transaction.type).to eq("sale")
|
@@ -477,7 +514,7 @@ describe Braintree::Transaction do
|
|
477
514
|
oauth_gateway = Braintree::Gateway.new(
|
478
515
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
479
516
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
480
|
-
:logger => Logger.new("/dev/null")
|
517
|
+
:logger => Logger.new("/dev/null"),
|
481
518
|
)
|
482
519
|
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
483
520
|
:merchant_public_id => "integration_merchant_id",
|
@@ -486,7 +523,7 @@ describe Braintree::Transaction do
|
|
486
523
|
|
487
524
|
gateway = Braintree::Gateway.new(
|
488
525
|
:access_token => access_token,
|
489
|
-
:logger => Logger.new("/dev/null")
|
526
|
+
:logger => Logger.new("/dev/null"),
|
490
527
|
)
|
491
528
|
|
492
529
|
result = gateway.transaction.create(
|
@@ -495,7 +532,7 @@ describe Braintree::Transaction do
|
|
495
532
|
:credit_card => {
|
496
533
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
497
534
|
:expiration_date => "05/2009"
|
498
|
-
}
|
535
|
+
},
|
499
536
|
)
|
500
537
|
|
501
538
|
result.success?.should == true
|
@@ -538,7 +575,7 @@ describe Braintree::Transaction do
|
|
538
575
|
:customer_ip => "192.168.0.1",
|
539
576
|
:customer_location_zip => "91244",
|
540
577
|
:customer_tenure => "20",
|
541
|
-
}
|
578
|
+
},
|
542
579
|
)
|
543
580
|
|
544
581
|
result.success?.should == true
|
@@ -548,7 +585,7 @@ describe Braintree::Transaction do
|
|
548
585
|
result = Braintree::Customer.create()
|
549
586
|
address_result = Braintree::Address.create(
|
550
587
|
:customer_id => result.customer.id,
|
551
|
-
:country_code_alpha2 => "US"
|
588
|
+
:country_code_alpha2 => "US",
|
552
589
|
)
|
553
590
|
|
554
591
|
result = Braintree::Transaction.create(
|
@@ -559,7 +596,7 @@ describe Braintree::Transaction do
|
|
559
596
|
:credit_card => {
|
560
597
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
561
598
|
:expiration_date => "05/2009"
|
562
|
-
}
|
599
|
+
},
|
563
600
|
)
|
564
601
|
|
565
602
|
result.success?.should == true
|
@@ -572,7 +609,7 @@ describe Braintree::Transaction do
|
|
572
609
|
:credit_card => {
|
573
610
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
574
611
|
:expiration_date => "05/2009"
|
575
|
-
}
|
612
|
+
},
|
576
613
|
)
|
577
614
|
result.success?.should == false
|
578
615
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -591,7 +628,7 @@ describe Braintree::Transaction do
|
|
591
628
|
:credit_card => {
|
592
629
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
593
630
|
:expiration_date => "05/2009"
|
594
|
-
}
|
631
|
+
},
|
595
632
|
)
|
596
633
|
result.success?.should == false
|
597
634
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -628,7 +665,7 @@ describe Braintree::Transaction do
|
|
628
665
|
:options => {
|
629
666
|
:add_billing_address_to_payment_method => true,
|
630
667
|
:store_in_vault => true
|
631
|
-
}
|
668
|
+
},
|
632
669
|
)
|
633
670
|
result.success?.should == true
|
634
671
|
transaction = result.transaction
|
@@ -658,7 +695,7 @@ describe Braintree::Transaction do
|
|
658
695
|
:billing => {
|
659
696
|
:country_name => "Botswana",
|
660
697
|
:country_code_alpha2 => "US",
|
661
|
-
}
|
698
|
+
},
|
662
699
|
)
|
663
700
|
|
664
701
|
result.success?.should == false
|
@@ -674,7 +711,7 @@ describe Braintree::Transaction do
|
|
674
711
|
},
|
675
712
|
:billing => {
|
676
713
|
:country_code_alpha2 => "ZZ"
|
677
|
-
}
|
714
|
+
},
|
678
715
|
)
|
679
716
|
|
680
717
|
result.success?.should == false
|
@@ -691,7 +728,7 @@ describe Braintree::Transaction do
|
|
691
728
|
},
|
692
729
|
:billing => {
|
693
730
|
:country_code_alpha3 => "ZZZ"
|
694
|
-
}
|
731
|
+
},
|
695
732
|
)
|
696
733
|
|
697
734
|
result.success?.should == false
|
@@ -708,7 +745,7 @@ describe Braintree::Transaction do
|
|
708
745
|
},
|
709
746
|
:billing => {
|
710
747
|
:country_code_numeric => "FOO"
|
711
|
-
}
|
748
|
+
},
|
712
749
|
)
|
713
750
|
|
714
751
|
result.success?.should == false
|
@@ -739,7 +776,7 @@ describe Braintree::Transaction do
|
|
739
776
|
},
|
740
777
|
:shipping => {
|
741
778
|
:phone_number => "123-234-3456=098765"
|
742
|
-
}
|
779
|
+
},
|
743
780
|
)
|
744
781
|
|
745
782
|
result.success?.should == false
|
@@ -755,7 +792,7 @@ describe Braintree::Transaction do
|
|
755
792
|
},
|
756
793
|
:shipping => {
|
757
794
|
:shipping_method => "urgent"
|
758
|
-
}
|
795
|
+
},
|
759
796
|
)
|
760
797
|
|
761
798
|
result.success?.should == false
|
@@ -771,7 +808,7 @@ describe Braintree::Transaction do
|
|
771
808
|
},
|
772
809
|
:billing => {
|
773
810
|
:phone_number => "123-234-3456=098765"
|
774
|
-
}
|
811
|
+
},
|
775
812
|
)
|
776
813
|
|
777
814
|
result.success?.should == false
|
@@ -795,7 +832,7 @@ describe Braintree::Transaction do
|
|
795
832
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
796
833
|
:expiration_date => "05/2009",
|
797
834
|
:cvv => "200"
|
798
|
-
}
|
835
|
+
},
|
799
836
|
)
|
800
837
|
result.success?.should == false
|
801
838
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::CVV
|
@@ -810,17 +847,17 @@ describe Braintree::Transaction do
|
|
810
847
|
gateway = Braintree::Gateway.new(
|
811
848
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
812
849
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
813
|
-
:logger => Logger.new("/dev/null")
|
850
|
+
:logger => Logger.new("/dev/null"),
|
814
851
|
)
|
815
852
|
result = gateway.merchant.create(
|
816
853
|
:email => "name@email.com",
|
817
854
|
:country_code_alpha3 => "USA",
|
818
|
-
:payment_methods => ["credit_card", "paypal"]
|
855
|
+
:payment_methods => ["credit_card", "paypal"],
|
819
856
|
)
|
820
857
|
|
821
858
|
gateway = Braintree::Gateway.new(
|
822
859
|
:access_token => result.credentials.access_token,
|
823
|
-
:logger => Logger.new("/dev/null")
|
860
|
+
:logger => Logger.new("/dev/null"),
|
824
861
|
)
|
825
862
|
|
826
863
|
result = gateway.transaction.create(
|
@@ -829,7 +866,7 @@ describe Braintree::Transaction do
|
|
829
866
|
:credit_card => {
|
830
867
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
831
868
|
:expiration_date => "05/2020"
|
832
|
-
}
|
869
|
+
},
|
833
870
|
)
|
834
871
|
result.success?.should == false
|
835
872
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete
|
@@ -853,7 +890,7 @@ describe Braintree::Transaction do
|
|
853
890
|
:credit_card => {
|
854
891
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
855
892
|
:expiration_date => "05/2009"
|
856
|
-
}
|
893
|
+
},
|
857
894
|
)
|
858
895
|
result.success?.should == false
|
859
896
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVS
|
@@ -883,7 +920,7 @@ describe Braintree::Transaction do
|
|
883
920
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
884
921
|
:expiration_date => "05/2009",
|
885
922
|
:cvv => "200"
|
886
|
-
}
|
923
|
+
},
|
887
924
|
)
|
888
925
|
result.success?.should == false
|
889
926
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVSAndCVV
|
@@ -895,14 +932,14 @@ describe Braintree::Transaction do
|
|
895
932
|
end
|
896
933
|
|
897
934
|
it "exposes the fraud gateway rejection reason" do
|
898
|
-
|
935
|
+
with_advanced_fraud_kount_integration_merchant do
|
899
936
|
result = Braintree::Transaction.sale(
|
900
937
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
901
938
|
:credit_card => {
|
902
939
|
:number => Braintree::Test::CreditCardNumbers::Fraud,
|
903
940
|
:expiration_date => "05/2017",
|
904
941
|
:cvv => "333"
|
905
|
-
}
|
942
|
+
},
|
906
943
|
)
|
907
944
|
result.success?.should == false
|
908
945
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::Fraud
|
@@ -910,14 +947,14 @@ describe Braintree::Transaction do
|
|
910
947
|
end
|
911
948
|
|
912
949
|
it "exposes the risk_threshold gateway rejection reason (via test cc num)" do
|
913
|
-
|
950
|
+
with_advanced_fraud_kount_integration_merchant do
|
914
951
|
result = Braintree::Transaction.sale(
|
915
952
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
916
953
|
:credit_card => {
|
917
954
|
:number => Braintree::Test::CreditCardNumbers::RiskThreshold,
|
918
955
|
:expiration_date => "05/2017",
|
919
956
|
:cvv => "333"
|
920
|
-
}
|
957
|
+
},
|
921
958
|
)
|
922
959
|
result.success?.should == false
|
923
960
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
|
@@ -925,7 +962,7 @@ describe Braintree::Transaction do
|
|
925
962
|
end
|
926
963
|
|
927
964
|
it "exposes the risk_threshold gateway rejection reason (via test test nonce)" do
|
928
|
-
|
965
|
+
with_advanced_fraud_kount_integration_merchant do
|
929
966
|
result = Braintree::Transaction.sale(
|
930
967
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
931
968
|
:payment_method_nonce => Braintree::Test::Nonce::GatewayRejectedRiskThresholds,
|
@@ -954,7 +991,7 @@ describe Braintree::Transaction do
|
|
954
991
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
955
992
|
:expiration_month => "05",
|
956
993
|
:expiration_year => "2011"
|
957
|
-
}
|
994
|
+
},
|
958
995
|
)
|
959
996
|
result.success?.should == true
|
960
997
|
result.transaction.credit_card_details.expiration_month.should == "05"
|
@@ -966,7 +1003,7 @@ describe Braintree::Transaction do
|
|
966
1003
|
result = Braintree::Transaction.create(
|
967
1004
|
:type => "sale",
|
968
1005
|
:amount => Braintree::Test::TransactionAmounts::Decline,
|
969
|
-
:customer_id => 123456789
|
1006
|
+
:customer_id => 123456789,
|
970
1007
|
)
|
971
1008
|
result.success?.should == false
|
972
1009
|
result.errors.for(:transaction).on(:customer_id)[0].code.should == "91510"
|
@@ -983,7 +1020,7 @@ describe Braintree::Transaction do
|
|
983
1020
|
},
|
984
1021
|
:custom_fields => {
|
985
1022
|
:store_me => "custom value"
|
986
|
-
}
|
1023
|
+
},
|
987
1024
|
)
|
988
1025
|
result.success?.should == true
|
989
1026
|
result.transaction.custom_fields.should == {:store_me => "custom value"}
|
@@ -998,7 +1035,7 @@ describe Braintree::Transaction do
|
|
998
1035
|
},
|
999
1036
|
:custom_fields => {
|
1000
1037
|
:store_me => ""
|
1001
|
-
}
|
1038
|
+
},
|
1002
1039
|
)
|
1003
1040
|
|
1004
1041
|
result = Braintree::Transaction.find(create_result.transaction.id)
|
@@ -1016,7 +1053,7 @@ describe Braintree::Transaction do
|
|
1016
1053
|
},
|
1017
1054
|
:custom_fields => {
|
1018
1055
|
:invalid_key => "custom value"
|
1019
|
-
}
|
1056
|
+
},
|
1020
1057
|
)
|
1021
1058
|
result.success?.should == false
|
1022
1059
|
result.errors.for(:transaction).on(:custom_fields)[0].message.should == "Custom field is invalid: invalid_key."
|
@@ -1035,7 +1072,7 @@ describe Braintree::Transaction do
|
|
1035
1072
|
}
|
1036
1073
|
result = Braintree::Transaction.create(params[:transaction])
|
1037
1074
|
result.success?.should == false
|
1038
|
-
result.params.should == {:transaction => {:type =>
|
1075
|
+
result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
1039
1076
|
end
|
1040
1077
|
|
1041
1078
|
it "returns errors if validations fail (tests many errors at once for spec speed)" do
|
@@ -1055,7 +1092,7 @@ describe Braintree::Transaction do
|
|
1055
1092
|
}
|
1056
1093
|
result = Braintree::Transaction.create(params[:transaction])
|
1057
1094
|
result.success?.should == false
|
1058
|
-
result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
|
1095
|
+
result.errors.for(:transaction).on(:base).map { |error| error.code }.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
|
1059
1096
|
result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
|
1060
1097
|
result.errors.for(:transaction).on(:payment_method_token)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodTokenIsInvalid
|
1061
1098
|
result.errors.for(:transaction).on(:type)[0].code.should == Braintree::ErrorCodes::Transaction::TypeIsInvalid
|
@@ -1086,7 +1123,7 @@ describe Braintree::Transaction do
|
|
1086
1123
|
:credit_card => {
|
1087
1124
|
:account_type => "credit",
|
1088
1125
|
}
|
1089
|
-
}
|
1126
|
+
},
|
1090
1127
|
)
|
1091
1128
|
result.success?.should == false
|
1092
1129
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountNotSupportedByProcessor
|
@@ -1130,13 +1167,13 @@ describe Braintree::Transaction do
|
|
1130
1167
|
:credit_card => {
|
1131
1168
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1132
1169
|
:expiration_date => "05/2010"
|
1133
|
-
}
|
1170
|
+
},
|
1134
1171
|
)
|
1135
1172
|
result = Braintree::Transaction.create(
|
1136
1173
|
:type => "sale",
|
1137
1174
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1138
1175
|
:customer_id => customer.id,
|
1139
|
-
:payment_method_token => customer.credit_cards[0].token + "x"
|
1176
|
+
:payment_method_token => customer.credit_cards[0].token + "x",
|
1140
1177
|
)
|
1141
1178
|
result.success?.should == false
|
1142
1179
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer
|
@@ -1148,7 +1185,7 @@ describe Braintree::Transaction do
|
|
1148
1185
|
:credit_card => {
|
1149
1186
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1150
1187
|
:expiration_date => "05/2010"
|
1151
|
-
}
|
1188
|
+
},
|
1152
1189
|
)
|
1153
1190
|
result = Braintree::Transaction.create(
|
1154
1191
|
:type => "sale",
|
@@ -1157,7 +1194,7 @@ describe Braintree::Transaction do
|
|
1157
1194
|
:credit_card => {
|
1158
1195
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1159
1196
|
:expiration_date => "12/12"
|
1160
|
-
}
|
1197
|
+
},
|
1161
1198
|
)
|
1162
1199
|
result.success?.should == true
|
1163
1200
|
result.transaction.credit_card_details.masked_number.should == "401288******1881"
|
@@ -1169,7 +1206,7 @@ describe Braintree::Transaction do
|
|
1169
1206
|
:credit_card => {
|
1170
1207
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1171
1208
|
:expiration_date => "05/2010"
|
1172
|
-
}
|
1209
|
+
},
|
1173
1210
|
)
|
1174
1211
|
result = Braintree::Transaction.create(
|
1175
1212
|
:type => "sale",
|
@@ -1179,7 +1216,7 @@ describe Braintree::Transaction do
|
|
1179
1216
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1180
1217
|
:expiration_date => "12/12",
|
1181
1218
|
},
|
1182
|
-
:options => {
|
1219
|
+
:options => {:store_in_vault => true},
|
1183
1220
|
)
|
1184
1221
|
result.success?.should == true
|
1185
1222
|
result.transaction.credit_card_details.masked_number.should == "401288******1881"
|
@@ -1193,7 +1230,7 @@ describe Braintree::Transaction do
|
|
1193
1230
|
:credit_card => {
|
1194
1231
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1195
1232
|
:expiration_date => "05/2010"
|
1196
|
-
}
|
1233
|
+
},
|
1197
1234
|
)
|
1198
1235
|
|
1199
1236
|
result = Braintree::Subscription.create(
|
@@ -1224,7 +1261,7 @@ describe Braintree::Transaction do
|
|
1224
1261
|
:never_expires => true
|
1225
1262
|
}
|
1226
1263
|
]
|
1227
|
-
}
|
1264
|
+
},
|
1228
1265
|
)
|
1229
1266
|
|
1230
1267
|
result.success?.should be(true)
|
@@ -1265,15 +1302,15 @@ describe Braintree::Transaction do
|
|
1265
1302
|
:expiration_date => "05/2009"
|
1266
1303
|
},
|
1267
1304
|
:descriptor => {
|
1268
|
-
:name =>
|
1269
|
-
:phone =>
|
1305
|
+
:name => "123*123456789012345678",
|
1306
|
+
:phone => "3334445555",
|
1270
1307
|
:url => "ebay.com"
|
1271
|
-
}
|
1308
|
+
},
|
1272
1309
|
)
|
1273
1310
|
result.success?.should == true
|
1274
|
-
result.transaction.descriptor.name.should ==
|
1275
|
-
result.transaction.descriptor.phone.should ==
|
1276
|
-
result.transaction.descriptor.url.should ==
|
1311
|
+
result.transaction.descriptor.name.should == "123*123456789012345678"
|
1312
|
+
result.transaction.descriptor.phone.should == "3334445555"
|
1313
|
+
result.transaction.descriptor.url.should == "ebay.com"
|
1277
1314
|
end
|
1278
1315
|
|
1279
1316
|
it "has validation errors if format is invalid" do
|
@@ -1284,10 +1321,10 @@ describe Braintree::Transaction do
|
|
1284
1321
|
:expiration_date => "05/2009"
|
1285
1322
|
},
|
1286
1323
|
:descriptor => {
|
1287
|
-
:name =>
|
1288
|
-
:phone =>
|
1289
|
-
:url =>
|
1290
|
-
}
|
1324
|
+
:name => "badcompanyname12*badproduct12",
|
1325
|
+
:phone => "%bad4445555",
|
1326
|
+
:url => "12345678901234"
|
1327
|
+
},
|
1291
1328
|
)
|
1292
1329
|
result.success?.should == false
|
1293
1330
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -1304,14 +1341,14 @@ describe Braintree::Transaction do
|
|
1304
1341
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1305
1342
|
:expiration_date => "05/2009"
|
1306
1343
|
},
|
1307
|
-
:tax_amount =>
|
1344
|
+
:tax_amount => "0.05",
|
1308
1345
|
:tax_exempt => false,
|
1309
|
-
:purchase_order_number =>
|
1346
|
+
:purchase_order_number => "12345678901234567",
|
1310
1347
|
)
|
1311
1348
|
result.success?.should == true
|
1312
1349
|
result.transaction.tax_amount.should == BigDecimal("0.05")
|
1313
1350
|
result.transaction.tax_exempt.should == false
|
1314
|
-
result.transaction.purchase_order_number.should ==
|
1351
|
+
result.transaction.purchase_order_number.should == "12345678901234567"
|
1315
1352
|
end
|
1316
1353
|
|
1317
1354
|
it "accepts tax_amount as a BigDecimal" do
|
@@ -1321,8 +1358,8 @@ describe Braintree::Transaction do
|
|
1321
1358
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1322
1359
|
:expiration_date => "05/2009"
|
1323
1360
|
},
|
1324
|
-
:tax_amount => BigDecimal(
|
1325
|
-
:tax_exempt => true
|
1361
|
+
:tax_amount => BigDecimal("1.99"),
|
1362
|
+
:tax_exempt => true,
|
1326
1363
|
)
|
1327
1364
|
result.success?.should == true
|
1328
1365
|
result.transaction.tax_amount.should == BigDecimal("1.99")
|
@@ -1338,7 +1375,7 @@ describe Braintree::Transaction do
|
|
1338
1375
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1339
1376
|
:expiration_date => "05/2009"
|
1340
1377
|
},
|
1341
|
-
:tax_amount =>
|
1378
|
+
:tax_amount => "abcd",
|
1342
1379
|
)
|
1343
1380
|
result.success?.should == false
|
1344
1381
|
result.errors.for(:transaction).on(:tax_amount)[0].code.should == Braintree::ErrorCodes::Transaction::TaxAmountFormatIsInvalid
|
@@ -1351,7 +1388,7 @@ describe Braintree::Transaction do
|
|
1351
1388
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1352
1389
|
:expiration_date => "05/2009"
|
1353
1390
|
},
|
1354
|
-
:purchase_order_number =>
|
1391
|
+
:purchase_order_number => "a" * 18,
|
1355
1392
|
)
|
1356
1393
|
result.success?.should == false
|
1357
1394
|
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsTooLong
|
@@ -1364,7 +1401,7 @@ describe Braintree::Transaction do
|
|
1364
1401
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1365
1402
|
:expiration_date => "05/2009"
|
1366
1403
|
},
|
1367
|
-
:purchase_order_number => "\303\237\303\245\342\210\202"
|
1404
|
+
:purchase_order_number => "\303\237\303\245\342\210\202",
|
1368
1405
|
)
|
1369
1406
|
result.success?.should == false
|
1370
1407
|
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsInvalid
|
@@ -1381,7 +1418,7 @@ describe Braintree::Transaction do
|
|
1381
1418
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1382
1419
|
:expiration_date => "12/12",
|
1383
1420
|
},
|
1384
|
-
:transaction_source => "recurring_first"
|
1421
|
+
:transaction_source => "recurring_first",
|
1385
1422
|
)
|
1386
1423
|
result.success?.should == true
|
1387
1424
|
result.transaction.recurring.should == true
|
@@ -1395,7 +1432,7 @@ describe Braintree::Transaction do
|
|
1395
1432
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1396
1433
|
:expiration_date => "12/12",
|
1397
1434
|
},
|
1398
|
-
:transaction_source => "recurring"
|
1435
|
+
:transaction_source => "recurring",
|
1399
1436
|
)
|
1400
1437
|
result.success?.should == true
|
1401
1438
|
result.transaction.recurring.should == true
|
@@ -1409,7 +1446,7 @@ describe Braintree::Transaction do
|
|
1409
1446
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1410
1447
|
:expiration_date => "12/12",
|
1411
1448
|
},
|
1412
|
-
:transaction_source => "merchant"
|
1449
|
+
:transaction_source => "merchant",
|
1413
1450
|
)
|
1414
1451
|
result.success?.should == true
|
1415
1452
|
result.transaction.recurring.should == false
|
@@ -1423,7 +1460,7 @@ describe Braintree::Transaction do
|
|
1423
1460
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1424
1461
|
:expiration_date => "12/12",
|
1425
1462
|
},
|
1426
|
-
:transaction_source => "moto"
|
1463
|
+
:transaction_source => "moto",
|
1427
1464
|
)
|
1428
1465
|
result.success?.should == true
|
1429
1466
|
result.transaction.recurring.should == false
|
@@ -1437,7 +1474,7 @@ describe Braintree::Transaction do
|
|
1437
1474
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1438
1475
|
:expiration_date => "12/12",
|
1439
1476
|
},
|
1440
|
-
:transaction_source => "invalid_value"
|
1477
|
+
:transaction_source => "invalid_value",
|
1441
1478
|
)
|
1442
1479
|
result.success?.should == false
|
1443
1480
|
result.errors.for(:transaction).on(:transaction_source)[0].code.should == Braintree::ErrorCodes::Transaction::TransactionSourceIsInvalid
|
@@ -1457,7 +1494,7 @@ describe Braintree::Transaction do
|
|
1457
1494
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1458
1495
|
:expiration_date => "12/12",
|
1459
1496
|
},
|
1460
|
-
:options => {
|
1497
|
+
:options => {:store_in_vault_on_success => true},
|
1461
1498
|
)
|
1462
1499
|
result.success?.should == true
|
1463
1500
|
result.transaction.vault_customer.last_name.should == "Doe"
|
@@ -1476,7 +1513,7 @@ describe Braintree::Transaction do
|
|
1476
1513
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1477
1514
|
:expiration_date => "12/12",
|
1478
1515
|
},
|
1479
|
-
:options => {
|
1516
|
+
:options => {:store_in_vault_on_success => true},
|
1480
1517
|
)
|
1481
1518
|
result.success?.should == false
|
1482
1519
|
result.transaction.vault_customer.should be_nil
|
@@ -1496,7 +1533,7 @@ describe Braintree::Transaction do
|
|
1496
1533
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1497
1534
|
:expiration_date => "12/12",
|
1498
1535
|
},
|
1499
|
-
:options => {
|
1536
|
+
:options => {:store_in_vault_on_success => false},
|
1500
1537
|
)
|
1501
1538
|
result.success?.should == true
|
1502
1539
|
result.transaction.vault_customer.should be_nil
|
@@ -1514,7 +1551,7 @@ describe Braintree::Transaction do
|
|
1514
1551
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1515
1552
|
:expiration_date => "12/12",
|
1516
1553
|
},
|
1517
|
-
:options => {
|
1554
|
+
:options => {:store_in_vault_on_success => false},
|
1518
1555
|
)
|
1519
1556
|
result.success?.should == false
|
1520
1557
|
result.transaction.vault_customer.should be_nil
|
@@ -1533,7 +1570,7 @@ describe Braintree::Transaction do
|
|
1533
1570
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1534
1571
|
:expiration_date => "12/12",
|
1535
1572
|
},
|
1536
|
-
:service_fee_amount => "1.00"
|
1573
|
+
:service_fee_amount => "1.00",
|
1537
1574
|
)
|
1538
1575
|
result.success?.should == true
|
1539
1576
|
result.transaction.service_fee_amount.should == BigDecimal("1.00")
|
@@ -1548,7 +1585,7 @@ describe Braintree::Transaction do
|
|
1548
1585
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1549
1586
|
:expiration_date => "12/12",
|
1550
1587
|
},
|
1551
|
-
:service_fee_amount => "1.00"
|
1588
|
+
:service_fee_amount => "1.00",
|
1552
1589
|
)
|
1553
1590
|
result.success?.should == false
|
1554
1591
|
expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
|
@@ -1563,7 +1600,7 @@ describe Braintree::Transaction do
|
|
1563
1600
|
:credit_card => {
|
1564
1601
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1565
1602
|
:expiration_date => "12/12",
|
1566
|
-
}
|
1603
|
+
},
|
1567
1604
|
)
|
1568
1605
|
result.success?.should == false
|
1569
1606
|
expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
|
@@ -1573,7 +1610,7 @@ describe Braintree::Transaction do
|
|
1573
1610
|
it "raises an error if service fee amount is negative" do
|
1574
1611
|
result = Braintree::Transaction.create(
|
1575
1612
|
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
1576
|
-
:service_fee_amount => "-1.00"
|
1613
|
+
:service_fee_amount => "-1.00",
|
1577
1614
|
)
|
1578
1615
|
result.success?.should == false
|
1579
1616
|
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative
|
@@ -1582,7 +1619,7 @@ describe Braintree::Transaction do
|
|
1582
1619
|
it "raises an error if service fee amount is invalid" do
|
1583
1620
|
result = Braintree::Transaction.create(
|
1584
1621
|
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
1585
|
-
:service_fee_amount => "invalid amount"
|
1622
|
+
:service_fee_amount => "invalid amount",
|
1586
1623
|
)
|
1587
1624
|
result.success?.should == false
|
1588
1625
|
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid
|
@@ -1600,7 +1637,7 @@ describe Braintree::Transaction do
|
|
1600
1637
|
:expiration_date => "12/12",
|
1601
1638
|
},
|
1602
1639
|
:service_fee_amount => "10.00",
|
1603
|
-
:options => {:hold_in_escrow => true}
|
1640
|
+
:options => {:hold_in_escrow => true},
|
1604
1641
|
)
|
1605
1642
|
|
1606
1643
|
result.success?.should == true
|
@@ -1617,7 +1654,7 @@ describe Braintree::Transaction do
|
|
1617
1654
|
:expiration_date => "12/12",
|
1618
1655
|
},
|
1619
1656
|
:service_fee_amount => "1.00",
|
1620
|
-
:options => {:hold_in_escrow => true}
|
1657
|
+
:options => {:hold_in_escrow => true},
|
1621
1658
|
)
|
1622
1659
|
result.success?.should == false
|
1623
1660
|
expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
|
@@ -1630,7 +1667,7 @@ describe Braintree::Transaction do
|
|
1630
1667
|
result = Braintree::Transaction.create(
|
1631
1668
|
:type => "sale",
|
1632
1669
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1633
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
1670
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
|
1634
1671
|
)
|
1635
1672
|
result.success?.should == true
|
1636
1673
|
result.transaction.credit_card_details.bin.should == "400934"
|
@@ -1647,7 +1684,7 @@ describe Braintree::Transaction do
|
|
1647
1684
|
},
|
1648
1685
|
:options => {
|
1649
1686
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
1650
|
-
}
|
1687
|
+
},
|
1651
1688
|
)
|
1652
1689
|
result.success?.should == true
|
1653
1690
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -1662,14 +1699,14 @@ describe Braintree::Transaction do
|
|
1662
1699
|
:expiration_month => "11",
|
1663
1700
|
:expiration_year => "2099",
|
1664
1701
|
},
|
1665
|
-
:share => true
|
1702
|
+
:share => true,
|
1666
1703
|
)
|
1667
1704
|
nonce.should_not be_nil
|
1668
1705
|
|
1669
1706
|
result = Braintree::Transaction.create(
|
1670
1707
|
:type => "sale",
|
1671
1708
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1672
|
-
:payment_method_nonce => nonce
|
1709
|
+
:payment_method_nonce => nonce,
|
1673
1710
|
)
|
1674
1711
|
result.success?.should == true
|
1675
1712
|
end
|
@@ -1684,14 +1721,14 @@ describe Braintree::Transaction do
|
|
1684
1721
|
},
|
1685
1722
|
:client_token_options => {
|
1686
1723
|
:customer_id => customer.id,
|
1687
|
-
}
|
1724
|
+
},
|
1688
1725
|
)
|
1689
1726
|
nonce.should_not be_nil
|
1690
1727
|
|
1691
1728
|
result = Braintree::Transaction.create(
|
1692
1729
|
:type => "sale",
|
1693
1730
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1694
|
-
:payment_method_nonce => nonce
|
1731
|
+
:payment_method_nonce => nonce,
|
1695
1732
|
)
|
1696
1733
|
result.success?.should == true
|
1697
1734
|
end
|
@@ -1704,14 +1741,14 @@ describe Braintree::Transaction do
|
|
1704
1741
|
},
|
1705
1742
|
:client_token_options => {
|
1706
1743
|
:customer_id => customer.id,
|
1707
|
-
}
|
1744
|
+
},
|
1708
1745
|
)
|
1709
1746
|
nonce.should_not be_nil
|
1710
1747
|
|
1711
1748
|
result = Braintree::Transaction.create(
|
1712
1749
|
:type => "sale",
|
1713
1750
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1714
|
-
:payment_method_nonce => nonce
|
1751
|
+
:payment_method_nonce => nonce,
|
1715
1752
|
)
|
1716
1753
|
result.success?.should == true
|
1717
1754
|
result.transaction.paypal_details.should_not be_nil
|
@@ -1723,14 +1760,14 @@ describe Braintree::Transaction do
|
|
1723
1760
|
nonce = nonce_for_new_payment_method(
|
1724
1761
|
:paypal_account => {
|
1725
1762
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1726
|
-
}
|
1763
|
+
},
|
1727
1764
|
)
|
1728
1765
|
nonce.should_not be_nil
|
1729
1766
|
|
1730
1767
|
result = Braintree::Transaction.create(
|
1731
1768
|
:type => "sale",
|
1732
1769
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1733
|
-
:payment_method_nonce => nonce
|
1770
|
+
:payment_method_nonce => nonce,
|
1734
1771
|
)
|
1735
1772
|
result.success?.should == true
|
1736
1773
|
result.transaction.paypal_details.should_not be_nil
|
@@ -1742,7 +1779,7 @@ describe Braintree::Transaction do
|
|
1742
1779
|
result = Braintree::Transaction.create(
|
1743
1780
|
:type => "sale",
|
1744
1781
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1745
|
-
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa
|
1782
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
1746
1783
|
)
|
1747
1784
|
result.success?.should == true
|
1748
1785
|
result.transaction.should_not be_nil
|
@@ -1772,7 +1809,7 @@ describe Braintree::Transaction do
|
|
1772
1809
|
:type => "sale",
|
1773
1810
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1774
1811
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
1775
|
-
:options => {
|
1812
|
+
:options => {:store_in_vault_on_success => true},
|
1776
1813
|
)
|
1777
1814
|
result.success?.should == true
|
1778
1815
|
result.transaction.should_not be_nil
|
@@ -1793,7 +1830,7 @@ describe Braintree::Transaction do
|
|
1793
1830
|
result = Braintree::Transaction.create(
|
1794
1831
|
:type => "sale",
|
1795
1832
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1796
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
1833
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1797
1834
|
)
|
1798
1835
|
result.success?.should == true
|
1799
1836
|
result.transaction.should_not be_nil
|
@@ -1826,7 +1863,7 @@ describe Braintree::Transaction do
|
|
1826
1863
|
:type => "sale",
|
1827
1864
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1828
1865
|
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1829
|
-
:options => {
|
1866
|
+
:options => {:store_in_vault_on_success => true},
|
1830
1867
|
)
|
1831
1868
|
result.success?.should == true
|
1832
1869
|
result.transaction.should_not be_nil
|
@@ -1850,7 +1887,7 @@ describe Braintree::Transaction do
|
|
1850
1887
|
result = Braintree::Transaction.create(
|
1851
1888
|
:type => "sale",
|
1852
1889
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1853
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1890
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1854
1891
|
)
|
1855
1892
|
result.success?.should == true
|
1856
1893
|
result.transaction.should_not be_nil
|
@@ -1873,7 +1910,7 @@ describe Braintree::Transaction do
|
|
1873
1910
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
1874
1911
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1875
1912
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1876
|
-
:options => {:store_in_vault => true}
|
1913
|
+
:options => {:store_in_vault => true},
|
1877
1914
|
)
|
1878
1915
|
result.should be_success
|
1879
1916
|
|
@@ -1893,7 +1930,7 @@ describe Braintree::Transaction do
|
|
1893
1930
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
1894
1931
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1895
1932
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1896
|
-
:options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id"
|
1933
|
+
:options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id"}},
|
1897
1934
|
)
|
1898
1935
|
result.should be_success
|
1899
1936
|
end
|
@@ -1903,7 +1940,7 @@ describe Braintree::Transaction do
|
|
1903
1940
|
result = Braintree::Transaction.create(
|
1904
1941
|
:type => "sale",
|
1905
1942
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1906
|
-
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable
|
1943
|
+
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
1907
1944
|
)
|
1908
1945
|
result.success?.should == true
|
1909
1946
|
result.transaction.should_not be_nil
|
@@ -1918,7 +1955,7 @@ describe Braintree::Transaction do
|
|
1918
1955
|
:paypal_account => {
|
1919
1956
|
:payer_id => "PAYER-1234",
|
1920
1957
|
:payment_id => "PAY-5678",
|
1921
|
-
}
|
1958
|
+
},
|
1922
1959
|
)
|
1923
1960
|
|
1924
1961
|
result.success?.should == true
|
@@ -1932,7 +1969,7 @@ describe Braintree::Transaction do
|
|
1932
1969
|
nonce = nonce_for_new_payment_method(
|
1933
1970
|
:paypal_account => {
|
1934
1971
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1935
|
-
}
|
1972
|
+
},
|
1936
1973
|
)
|
1937
1974
|
nonce.should_not be_nil
|
1938
1975
|
|
@@ -1942,7 +1979,7 @@ describe Braintree::Transaction do
|
|
1942
1979
|
:payment_method_nonce => nonce,
|
1943
1980
|
:paypal_account => {
|
1944
1981
|
:payee_id => "fake-payee-id"
|
1945
|
-
}
|
1982
|
+
},
|
1946
1983
|
)
|
1947
1984
|
|
1948
1985
|
result.success?.should == true
|
@@ -1956,7 +1993,7 @@ describe Braintree::Transaction do
|
|
1956
1993
|
nonce = nonce_for_new_payment_method(
|
1957
1994
|
:paypal_account => {
|
1958
1995
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1959
|
-
}
|
1996
|
+
},
|
1960
1997
|
)
|
1961
1998
|
nonce.should_not be_nil
|
1962
1999
|
|
@@ -1967,7 +2004,7 @@ describe Braintree::Transaction do
|
|
1967
2004
|
:paypal_account => {},
|
1968
2005
|
:options => {
|
1969
2006
|
:payee_id => "fake-payee-id"
|
1970
|
-
}
|
2007
|
+
},
|
1971
2008
|
)
|
1972
2009
|
|
1973
2010
|
result.success?.should == true
|
@@ -1981,7 +2018,7 @@ describe Braintree::Transaction do
|
|
1981
2018
|
nonce = nonce_for_new_payment_method(
|
1982
2019
|
:paypal_account => {
|
1983
2020
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1984
|
-
}
|
2021
|
+
},
|
1985
2022
|
)
|
1986
2023
|
nonce.should_not be_nil
|
1987
2024
|
|
@@ -1993,7 +2030,7 @@ describe Braintree::Transaction do
|
|
1993
2030
|
:paypal => {
|
1994
2031
|
:payee_id => "fake-payee-id"
|
1995
2032
|
}
|
1996
|
-
}
|
2033
|
+
},
|
1997
2034
|
)
|
1998
2035
|
|
1999
2036
|
result.success?.should == true
|
@@ -2007,7 +2044,7 @@ describe Braintree::Transaction do
|
|
2007
2044
|
nonce = nonce_for_new_payment_method(
|
2008
2045
|
:paypal_account => {
|
2009
2046
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2010
|
-
}
|
2047
|
+
},
|
2011
2048
|
)
|
2012
2049
|
nonce.should_not be_nil
|
2013
2050
|
|
@@ -2017,7 +2054,7 @@ describe Braintree::Transaction do
|
|
2017
2054
|
:payment_method_nonce => nonce,
|
2018
2055
|
:paypal_account => {
|
2019
2056
|
:payee_email => "bt_seller_us@paypal.com"
|
2020
|
-
}
|
2057
|
+
},
|
2021
2058
|
)
|
2022
2059
|
|
2023
2060
|
result.success?.should == true
|
@@ -2031,7 +2068,7 @@ describe Braintree::Transaction do
|
|
2031
2068
|
nonce = nonce_for_new_payment_method(
|
2032
2069
|
:paypal_account => {
|
2033
2070
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2034
|
-
}
|
2071
|
+
},
|
2035
2072
|
)
|
2036
2073
|
nonce.should_not be_nil
|
2037
2074
|
|
@@ -2042,7 +2079,7 @@ describe Braintree::Transaction do
|
|
2042
2079
|
:paypal_account => {},
|
2043
2080
|
:options => {
|
2044
2081
|
:payee_email => "bt_seller_us@paypal.com"
|
2045
|
-
}
|
2082
|
+
},
|
2046
2083
|
)
|
2047
2084
|
|
2048
2085
|
result.success?.should == true
|
@@ -2056,7 +2093,7 @@ describe Braintree::Transaction do
|
|
2056
2093
|
nonce = nonce_for_new_payment_method(
|
2057
2094
|
:paypal_account => {
|
2058
2095
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2059
|
-
}
|
2096
|
+
},
|
2060
2097
|
)
|
2061
2098
|
nonce.should_not be_nil
|
2062
2099
|
|
@@ -2068,7 +2105,7 @@ describe Braintree::Transaction do
|
|
2068
2105
|
:paypal => {
|
2069
2106
|
:payee_email => "bt_seller_us@paypal.com"
|
2070
2107
|
}
|
2071
|
-
}
|
2108
|
+
},
|
2072
2109
|
)
|
2073
2110
|
|
2074
2111
|
result.success?.should == true
|
@@ -2082,7 +2119,7 @@ describe Braintree::Transaction do
|
|
2082
2119
|
nonce = nonce_for_new_payment_method(
|
2083
2120
|
:paypal_account => {
|
2084
2121
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2085
|
-
}
|
2122
|
+
},
|
2086
2123
|
)
|
2087
2124
|
nonce.should_not be_nil
|
2088
2125
|
|
@@ -2094,7 +2131,7 @@ describe Braintree::Transaction do
|
|
2094
2131
|
:paypal => {
|
2095
2132
|
:custom_field => "Additional info"
|
2096
2133
|
}
|
2097
|
-
}
|
2134
|
+
},
|
2098
2135
|
)
|
2099
2136
|
|
2100
2137
|
result.success?.should == true
|
@@ -2108,7 +2145,7 @@ describe Braintree::Transaction do
|
|
2108
2145
|
nonce = nonce_for_new_payment_method(
|
2109
2146
|
:paypal_account => {
|
2110
2147
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2111
|
-
}
|
2148
|
+
},
|
2112
2149
|
)
|
2113
2150
|
nonce.should_not be_nil
|
2114
2151
|
|
@@ -2120,7 +2157,7 @@ describe Braintree::Transaction do
|
|
2120
2157
|
:paypal => {
|
2121
2158
|
:description => "A great product"
|
2122
2159
|
}
|
2123
|
-
}
|
2160
|
+
},
|
2124
2161
|
)
|
2125
2162
|
|
2126
2163
|
result.success?.should == true
|
@@ -2134,7 +2171,7 @@ describe Braintree::Transaction do
|
|
2134
2171
|
nonce = nonce_for_new_payment_method(
|
2135
2172
|
:paypal_account => {
|
2136
2173
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2137
|
-
}
|
2174
|
+
},
|
2138
2175
|
)
|
2139
2176
|
nonce.should_not be_nil
|
2140
2177
|
|
@@ -2149,7 +2186,7 @@ describe Braintree::Transaction do
|
|
2149
2186
|
:key2 => "value2",
|
2150
2187
|
}
|
2151
2188
|
}
|
2152
|
-
}
|
2189
|
+
},
|
2153
2190
|
)
|
2154
2191
|
|
2155
2192
|
# note - supplementary data is not returned in response
|
@@ -2163,7 +2200,7 @@ describe Braintree::Transaction do
|
|
2163
2200
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2164
2201
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2165
2202
|
:expiration_month => "12",
|
2166
|
-
:expiration_year => "2012"
|
2203
|
+
:expiration_year => "2012",
|
2167
2204
|
)
|
2168
2205
|
|
2169
2206
|
result = Braintree::Transaction.create(
|
@@ -2174,7 +2211,7 @@ describe Braintree::Transaction do
|
|
2174
2211
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2175
2212
|
:expiration_date => "12/12",
|
2176
2213
|
},
|
2177
|
-
:three_d_secure_token => three_d_secure_token
|
2214
|
+
:three_d_secure_token => three_d_secure_token,
|
2178
2215
|
)
|
2179
2216
|
|
2180
2217
|
result.success?.should == true
|
@@ -2186,7 +2223,7 @@ describe Braintree::Transaction do
|
|
2186
2223
|
:number => "4111111111111111",
|
2187
2224
|
:expiration_month => "11",
|
2188
2225
|
:expiration_year => "2099",
|
2189
|
-
}
|
2226
|
+
},
|
2190
2227
|
)
|
2191
2228
|
nonce.should_not be_nil
|
2192
2229
|
result = Braintree::Transaction.create(
|
@@ -2198,7 +2235,7 @@ describe Braintree::Transaction do
|
|
2198
2235
|
:three_d_secure => {
|
2199
2236
|
:required => true,
|
2200
2237
|
}
|
2201
|
-
}
|
2238
|
+
},
|
2202
2239
|
)
|
2203
2240
|
|
2204
2241
|
result.success?.should == false
|
@@ -2214,7 +2251,7 @@ describe Braintree::Transaction do
|
|
2214
2251
|
:credit_card => {
|
2215
2252
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2216
2253
|
:expiration_date => "12/12",
|
2217
|
-
}
|
2254
|
+
},
|
2218
2255
|
)
|
2219
2256
|
result.success?.should == true
|
2220
2257
|
end
|
@@ -2225,7 +2262,7 @@ describe Braintree::Transaction do
|
|
2225
2262
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2226
2263
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2227
2264
|
:expiration_month => "12",
|
2228
|
-
:expiration_year => "2022"
|
2265
|
+
:expiration_year => "2022",
|
2229
2266
|
)
|
2230
2267
|
|
2231
2268
|
result = Braintree::Transaction.create(
|
@@ -2236,7 +2273,7 @@ describe Braintree::Transaction do
|
|
2236
2273
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2237
2274
|
:expiration_date => "12/22",
|
2238
2275
|
},
|
2239
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2276
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2240
2277
|
)
|
2241
2278
|
|
2242
2279
|
result.success?.should == true
|
@@ -2250,7 +2287,7 @@ describe Braintree::Transaction do
|
|
2250
2287
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2251
2288
|
:expiration_date => "12/12",
|
2252
2289
|
},
|
2253
|
-
:three_d_secure_authentication_id => nil
|
2290
|
+
:three_d_secure_authentication_id => nil,
|
2254
2291
|
)
|
2255
2292
|
result.success?.should == false
|
2256
2293
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdIsInvalid
|
@@ -2260,7 +2297,7 @@ describe Braintree::Transaction do
|
|
2260
2297
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2261
2298
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2262
2299
|
:expiration_month => "12",
|
2263
|
-
:expiration_year => "2012"
|
2300
|
+
:expiration_year => "2012",
|
2264
2301
|
)
|
2265
2302
|
|
2266
2303
|
result = Braintree::Transaction.create(
|
@@ -2270,7 +2307,7 @@ describe Braintree::Transaction do
|
|
2270
2307
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2271
2308
|
:expiration_date => "12/12",
|
2272
2309
|
},
|
2273
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2310
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2274
2311
|
)
|
2275
2312
|
result.success?.should == false
|
2276
2313
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
|
@@ -2280,7 +2317,7 @@ describe Braintree::Transaction do
|
|
2280
2317
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2281
2318
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2282
2319
|
:expiration_month => "12",
|
2283
|
-
:expiration_year => "2012"
|
2320
|
+
:expiration_year => "2012",
|
2284
2321
|
)
|
2285
2322
|
|
2286
2323
|
result = Braintree::Transaction.create(
|
@@ -2291,7 +2328,7 @@ describe Braintree::Transaction do
|
|
2291
2328
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2292
2329
|
:expiration_date => "12/12",
|
2293
2330
|
},
|
2294
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2331
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2295
2332
|
)
|
2296
2333
|
result.success?.should == false
|
2297
2334
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
|
@@ -2301,7 +2338,7 @@ describe Braintree::Transaction do
|
|
2301
2338
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2302
2339
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2303
2340
|
:expiration_month => "12",
|
2304
|
-
:expiration_year => "2012"
|
2341
|
+
:expiration_year => "2012",
|
2305
2342
|
)
|
2306
2343
|
result = Braintree::Transaction.create(
|
2307
2344
|
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
|
@@ -2321,7 +2358,7 @@ describe Braintree::Transaction do
|
|
2321
2358
|
:directory_response => "Y",
|
2322
2359
|
:cavv_algorithm => "2",
|
2323
2360
|
:ds_transaction_id => "some_ds_id",
|
2324
|
-
}
|
2361
|
+
},
|
2325
2362
|
)
|
2326
2363
|
result.success?.should == false
|
2327
2364
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdWithThreeDSecurePassThruIsInvalid
|
@@ -2334,7 +2371,7 @@ describe Braintree::Transaction do
|
|
2334
2371
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2335
2372
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2336
2373
|
:expiration_month => "12",
|
2337
|
-
:expiration_year => "2012"
|
2374
|
+
:expiration_year => "2012",
|
2338
2375
|
)
|
2339
2376
|
|
2340
2377
|
result = Braintree::Transaction.create(
|
@@ -2345,7 +2382,7 @@ describe Braintree::Transaction do
|
|
2345
2382
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2346
2383
|
:expiration_date => "12/12",
|
2347
2384
|
},
|
2348
|
-
:three_d_secure_token => three_d_secure_token
|
2385
|
+
:three_d_secure_token => three_d_secure_token,
|
2349
2386
|
)
|
2350
2387
|
|
2351
2388
|
result.success?.should == true
|
@@ -2360,7 +2397,7 @@ describe Braintree::Transaction do
|
|
2360
2397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2361
2398
|
:expiration_date => "12/12",
|
2362
2399
|
},
|
2363
|
-
:three_d_secure_token => nil
|
2400
|
+
:three_d_secure_token => nil,
|
2364
2401
|
)
|
2365
2402
|
result.success?.should == false
|
2366
2403
|
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTokenIsInvalid
|
@@ -2371,7 +2408,7 @@ describe Braintree::Transaction do
|
|
2371
2408
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2372
2409
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2373
2410
|
:expiration_month => "12",
|
2374
|
-
:expiration_year => "2012"
|
2411
|
+
:expiration_year => "2012",
|
2375
2412
|
)
|
2376
2413
|
|
2377
2414
|
result = Braintree::Transaction.create(
|
@@ -2382,7 +2419,7 @@ describe Braintree::Transaction do
|
|
2382
2419
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2383
2420
|
:expiration_date => "12/12",
|
2384
2421
|
},
|
2385
|
-
:three_d_secure_token => three_d_secure_token
|
2422
|
+
:three_d_secure_token => three_d_secure_token,
|
2386
2423
|
)
|
2387
2424
|
result.success?.should == false
|
2388
2425
|
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionDataDoesntMatchVerify
|
@@ -2406,7 +2443,7 @@ describe Braintree::Transaction do
|
|
2406
2443
|
:directory_response => "Y",
|
2407
2444
|
:cavv_algorithm => "2",
|
2408
2445
|
:ds_transaction_id => "some_ds_id",
|
2409
|
-
}
|
2446
|
+
},
|
2410
2447
|
)
|
2411
2448
|
|
2412
2449
|
result.success?.should == true
|
@@ -2431,7 +2468,7 @@ describe Braintree::Transaction do
|
|
2431
2468
|
:directory_response => "Y",
|
2432
2469
|
:cavv_algorithm => "2",
|
2433
2470
|
:ds_transaction_id => "some_ds_id",
|
2434
|
-
}
|
2471
|
+
},
|
2435
2472
|
)
|
2436
2473
|
result.success?.should == false
|
2437
2474
|
result.errors.for(:transaction).on(:merchant_account_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureMerchantAccountDoesNotSupportCardType
|
@@ -2449,7 +2486,7 @@ describe Braintree::Transaction do
|
|
2449
2486
|
:eci_flag => "",
|
2450
2487
|
:cavv => "some_cavv",
|
2451
2488
|
:xid => "some_xid",
|
2452
|
-
}
|
2489
|
+
},
|
2453
2490
|
)
|
2454
2491
|
result.success?.should == false
|
2455
2492
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsRequired
|
@@ -2472,7 +2509,7 @@ describe Braintree::Transaction do
|
|
2472
2509
|
:directory_response => "Y",
|
2473
2510
|
:cavv_algorithm => "2",
|
2474
2511
|
:ds_transaction_id => "some_ds_id",
|
2475
|
-
}
|
2512
|
+
},
|
2476
2513
|
)
|
2477
2514
|
result.success?.should == false
|
2478
2515
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvIsRequired
|
@@ -2495,7 +2532,7 @@ describe Braintree::Transaction do
|
|
2495
2532
|
:directory_response => "Y",
|
2496
2533
|
:cavv_algorithm => "2",
|
2497
2534
|
:ds_transaction_id => "some_ds_id",
|
2498
|
-
}
|
2535
|
+
},
|
2499
2536
|
)
|
2500
2537
|
result.success?.should == false
|
2501
2538
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsInvalid
|
@@ -2518,7 +2555,7 @@ describe Braintree::Transaction do
|
|
2518
2555
|
:directory_response => "Y",
|
2519
2556
|
:cavv_algorithm => "2",
|
2520
2557
|
:ds_transaction_id => "some_ds_id",
|
2521
|
-
}
|
2558
|
+
},
|
2522
2559
|
)
|
2523
2560
|
result.success?.should == false
|
2524
2561
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid
|
@@ -2542,7 +2579,7 @@ describe Braintree::Transaction do
|
|
2542
2579
|
:directory_response => "Y",
|
2543
2580
|
:cavv_algorithm => "2",
|
2544
2581
|
:ds_transaction_id => "some_ds_id",
|
2545
|
-
}
|
2582
|
+
},
|
2546
2583
|
)
|
2547
2584
|
result.success?.should == false
|
2548
2585
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid
|
@@ -2566,7 +2603,7 @@ describe Braintree::Transaction do
|
|
2566
2603
|
:directory_response => "abc",
|
2567
2604
|
:cavv_algorithm => "2",
|
2568
2605
|
:ds_transaction_id => "some_ds_id",
|
2569
|
-
}
|
2606
|
+
},
|
2570
2607
|
)
|
2571
2608
|
result.success?.should == false
|
2572
2609
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:directory_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureDirectoryResponseIsInvalid
|
@@ -2590,7 +2627,7 @@ describe Braintree::Transaction do
|
|
2590
2627
|
:directory_response => "Y",
|
2591
2628
|
:cavv_algorithm => "bad_alg",
|
2592
2629
|
:ds_transaction_id => "some_ds_id",
|
2593
|
-
}
|
2630
|
+
},
|
2594
2631
|
)
|
2595
2632
|
result.success?.should == false
|
2596
2633
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv_algorithm)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvAlgorithmIsInvalid
|
@@ -2602,12 +2639,12 @@ describe Braintree::Transaction do
|
|
2602
2639
|
it "can create a transaction" do
|
2603
2640
|
payment_method_result = Braintree::PaymentMethod.create(
|
2604
2641
|
:customer_id => Braintree::Customer.create.customer.id,
|
2605
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
2642
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
2606
2643
|
)
|
2607
2644
|
result = Braintree::Transaction.create(
|
2608
2645
|
:type => "sale",
|
2609
2646
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2610
|
-
:payment_method_token => payment_method_result.payment_method.token
|
2647
|
+
:payment_method_token => payment_method_result.payment_method.token,
|
2611
2648
|
)
|
2612
2649
|
|
2613
2650
|
result.should be_success
|
@@ -2622,13 +2659,13 @@ describe Braintree::Transaction do
|
|
2622
2659
|
payment_method_token = rand(36**3).to_s(36)
|
2623
2660
|
nonce = nonce_for_paypal_account(
|
2624
2661
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2625
|
-
:token => payment_method_token
|
2662
|
+
:token => payment_method_token,
|
2626
2663
|
)
|
2627
2664
|
|
2628
2665
|
result = Braintree::Transaction.create(
|
2629
2666
|
:type => "sale",
|
2630
2667
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2631
|
-
:payment_method_nonce => nonce
|
2668
|
+
:payment_method_nonce => nonce,
|
2632
2669
|
)
|
2633
2670
|
|
2634
2671
|
result.should be_success
|
@@ -2644,14 +2681,14 @@ describe Braintree::Transaction do
|
|
2644
2681
|
payment_method_token = rand(36**3).to_s(36)
|
2645
2682
|
nonce = nonce_for_paypal_account(
|
2646
2683
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2647
|
-
:token => payment_method_token
|
2684
|
+
:token => payment_method_token,
|
2648
2685
|
)
|
2649
2686
|
|
2650
2687
|
result = Braintree::Transaction.create(
|
2651
2688
|
:type => "sale",
|
2652
2689
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2653
2690
|
:payment_method_nonce => nonce,
|
2654
|
-
:options => {:store_in_vault => true}
|
2691
|
+
:options => {:store_in_vault => true},
|
2655
2692
|
)
|
2656
2693
|
|
2657
2694
|
result.success?.should == true
|
@@ -2670,7 +2707,7 @@ describe Braintree::Transaction do
|
|
2670
2707
|
:type => "sale",
|
2671
2708
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2672
2709
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
2673
|
-
:options => {:store_in_vault => true}
|
2710
|
+
:options => {:store_in_vault => true},
|
2674
2711
|
)
|
2675
2712
|
|
2676
2713
|
result.should be_success
|
@@ -2685,7 +2722,7 @@ describe Braintree::Transaction do
|
|
2685
2722
|
result = Braintree::Transaction.create(
|
2686
2723
|
:type => "sale",
|
2687
2724
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2688
|
-
:payment_method_nonce => Braintree::Test::Nonce::LocalPayment
|
2725
|
+
:payment_method_nonce => Braintree::Test::Nonce::LocalPayment,
|
2689
2726
|
)
|
2690
2727
|
|
2691
2728
|
result.should be_success
|
@@ -2703,7 +2740,7 @@ describe Braintree::Transaction do
|
|
2703
2740
|
result = Braintree::Transaction.create(
|
2704
2741
|
:type => "sale",
|
2705
2742
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2706
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2743
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2707
2744
|
)
|
2708
2745
|
|
2709
2746
|
result.should be_success
|
@@ -2715,14 +2752,14 @@ describe Braintree::Transaction do
|
|
2715
2752
|
payment_method_token = rand(36**3).to_s(36)
|
2716
2753
|
nonce = nonce_for_paypal_account(
|
2717
2754
|
:access_token => "PAYPAL_ACCESS_TOKEN",
|
2718
|
-
:token => payment_method_token
|
2755
|
+
:token => payment_method_token,
|
2719
2756
|
)
|
2720
2757
|
|
2721
2758
|
result = Braintree::Transaction.create(
|
2722
2759
|
:type => "sale",
|
2723
2760
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2724
2761
|
:payment_method_nonce => nonce,
|
2725
|
-
:options => {:store_in_vault => true}
|
2762
|
+
:options => {:store_in_vault => true},
|
2726
2763
|
)
|
2727
2764
|
|
2728
2765
|
result.success?.should == true
|
@@ -2742,7 +2779,7 @@ describe Braintree::Transaction do
|
|
2742
2779
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2743
2780
|
:options => {
|
2744
2781
|
:submit_for_settlement => true
|
2745
|
-
}
|
2782
|
+
},
|
2746
2783
|
)
|
2747
2784
|
result.success?.should == true
|
2748
2785
|
result.transaction.status.should == Braintree::Transaction::Status::Settling
|
@@ -2753,7 +2790,7 @@ describe Braintree::Transaction do
|
|
2753
2790
|
it "successfully voids a paypal transaction that's been authorized" do
|
2754
2791
|
sale_transaction = Braintree::Transaction.sale!(
|
2755
2792
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2756
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2793
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2757
2794
|
)
|
2758
2795
|
|
2759
2796
|
void_transaction = Braintree::Transaction.void!(sale_transaction.id)
|
@@ -2764,7 +2801,7 @@ describe Braintree::Transaction do
|
|
2764
2801
|
it "fails to void a paypal transaction that's been declined" do
|
2765
2802
|
sale_transaction = Braintree::Transaction.sale(
|
2766
2803
|
:amount => Braintree::Test::TransactionAmounts::Decline,
|
2767
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2804
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2768
2805
|
).transaction
|
2769
2806
|
|
2770
2807
|
expect do
|
@@ -2834,6 +2871,19 @@ describe Braintree::Transaction do
|
|
2834
2871
|
result.transaction.amount.should == transaction.amount/2
|
2835
2872
|
end
|
2836
2873
|
|
2874
|
+
it "allows merchant_account_id to be passed for the refund" do
|
2875
|
+
transaction = create_transaction_to_refund
|
2876
|
+
|
2877
|
+
result = Braintree::Transaction.refund(
|
2878
|
+
transaction.id,
|
2879
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
2880
|
+
)
|
2881
|
+
|
2882
|
+
result.success?.should == true
|
2883
|
+
result.transaction.type.should == "credit"
|
2884
|
+
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
2885
|
+
end
|
2886
|
+
|
2837
2887
|
it "does not allow arbitrary options to be passed" do
|
2838
2888
|
transaction = create_paypal_transaction_for_refund
|
2839
2889
|
|
@@ -2852,7 +2902,7 @@ describe Braintree::Transaction do
|
|
2852
2902
|
it "returns an error result if unsettled" do
|
2853
2903
|
transaction = Braintree::Transaction.sale!(
|
2854
2904
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2855
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2905
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2856
2906
|
)
|
2857
2907
|
result = Braintree::Transaction.refund(transaction.id)
|
2858
2908
|
result.success?.should == false
|
@@ -2865,7 +2915,7 @@ describe Braintree::Transaction do
|
|
2865
2915
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
2866
2916
|
:options => {
|
2867
2917
|
:submit_for_settlement => true
|
2868
|
-
}
|
2918
|
+
},
|
2869
2919
|
)
|
2870
2920
|
config = Braintree::Configuration.instantiate
|
2871
2921
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
@@ -2886,7 +2936,7 @@ describe Braintree::Transaction do
|
|
2886
2936
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
2887
2937
|
:options => {
|
2888
2938
|
:submit_for_settlement => true
|
2889
|
-
}
|
2939
|
+
},
|
2890
2940
|
)
|
2891
2941
|
config = Braintree::Configuration.instantiate
|
2892
2942
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
@@ -2906,13 +2956,13 @@ describe Braintree::Transaction do
|
|
2906
2956
|
it "handles bad unvalidated nonces" do
|
2907
2957
|
nonce = nonce_for_paypal_account(
|
2908
2958
|
:access_token => "PAYPAL_ACCESS_TOKEN",
|
2909
|
-
:consent_code => "PAYPAL_CONSENT_CODE"
|
2959
|
+
:consent_code => "PAYPAL_CONSENT_CODE",
|
2910
2960
|
)
|
2911
2961
|
|
2912
2962
|
result = Braintree::Transaction.create(
|
2913
2963
|
:type => "sale",
|
2914
2964
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2915
|
-
:payment_method_nonce => nonce
|
2965
|
+
:payment_method_nonce => nonce,
|
2916
2966
|
)
|
2917
2967
|
|
2918
2968
|
result.should_not be_success
|
@@ -2923,7 +2973,7 @@ describe Braintree::Transaction do
|
|
2923
2973
|
result = Braintree::Transaction.create(
|
2924
2974
|
:type => "sale",
|
2925
2975
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2926
|
-
:payment_method_nonce => "NON_EXISTENT_NONCE"
|
2976
|
+
:payment_method_nonce => "NON_EXISTENT_NONCE",
|
2927
2977
|
)
|
2928
2978
|
|
2929
2979
|
result.should_not be_success
|
@@ -4051,7 +4101,7 @@ describe Braintree::Transaction do
|
|
4051
4101
|
:unit_of_measure => "gallon",
|
4052
4102
|
:total_amount => "10.1",
|
4053
4103
|
},
|
4054
|
-
[
|
4104
|
+
["Name #2"],
|
4055
4105
|
{
|
4056
4106
|
:quantity => "2.02",
|
4057
4107
|
:name => "Name #3",
|
@@ -4237,7 +4287,7 @@ describe Braintree::Transaction do
|
|
4237
4287
|
customer = Braintree::Customer.create!
|
4238
4288
|
result = Braintree::PaymentMethod.create(
|
4239
4289
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
4240
|
-
:customer_id => customer.id
|
4290
|
+
:customer_id => customer.id,
|
4241
4291
|
)
|
4242
4292
|
payment_method_token = result.payment_method.token
|
4243
4293
|
|
@@ -4270,7 +4320,7 @@ describe Braintree::Transaction do
|
|
4270
4320
|
result.errors.for(:transaction).for(:external_vault).on(:status)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::StatusIsInvalid
|
4271
4321
|
end
|
4272
4322
|
|
4273
|
-
context "Visa/Mastercard/Discover" do
|
4323
|
+
context "Visa/Mastercard/Discover/AmEx" do
|
4274
4324
|
it "accepts status" do
|
4275
4325
|
result = Braintree::Transaction.create(
|
4276
4326
|
:type => "sale",
|
@@ -4322,12 +4372,12 @@ describe Braintree::Transaction do
|
|
4322
4372
|
end
|
4323
4373
|
end
|
4324
4374
|
|
4325
|
-
context "Non-(Visa/Mastercard/Discover) card types" do
|
4375
|
+
context "Non-(Visa/Mastercard/Discover/AmEx) card types" do
|
4326
4376
|
it "accepts status" do
|
4327
4377
|
result = Braintree::Transaction.create(
|
4328
4378
|
:type => "sale",
|
4329
4379
|
:credit_card => {
|
4330
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4380
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4331
4381
|
:expiration_date => "05/2009"
|
4332
4382
|
},
|
4333
4383
|
:external_vault => {
|
@@ -4336,14 +4386,14 @@ describe Braintree::Transaction do
|
|
4336
4386
|
:amount => "10.00",
|
4337
4387
|
)
|
4338
4388
|
result.success?.should == true
|
4339
|
-
result.transaction.network_transaction_id.
|
4389
|
+
result.transaction.network_transaction_id.should_not be_nil
|
4340
4390
|
end
|
4341
4391
|
|
4342
4392
|
it "accepts blank previous_network_transaction_id" do
|
4343
4393
|
result = Braintree::Transaction.create(
|
4344
4394
|
:type => "sale",
|
4345
4395
|
:credit_card => {
|
4346
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4396
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4347
4397
|
:expiration_date => "05/2009"
|
4348
4398
|
},
|
4349
4399
|
:external_vault => {
|
@@ -4353,27 +4403,9 @@ describe Braintree::Transaction do
|
|
4353
4403
|
:amount => "10.00",
|
4354
4404
|
)
|
4355
4405
|
result.success?.should == true
|
4356
|
-
result.transaction.network_transaction_id.
|
4357
|
-
end
|
4358
|
-
|
4359
|
-
it "rejects previous_network_transaction_id" do
|
4360
|
-
result = Braintree::Transaction.create(
|
4361
|
-
:type => "sale",
|
4362
|
-
:credit_card => {
|
4363
|
-
:number => Braintree::Test::CreditCardNumbers::AmExes[0],
|
4364
|
-
:expiration_date => "05/2009"
|
4365
|
-
},
|
4366
|
-
:external_vault => {
|
4367
|
-
:status => Braintree::Transaction::ExternalVault::Status::Vaulted,
|
4368
|
-
:previous_network_transaction_id => "123456789012345",
|
4369
|
-
},
|
4370
|
-
:amount => "10.00",
|
4371
|
-
)
|
4372
|
-
result.success?.should == false
|
4373
|
-
result.errors.for(:transaction).for(:external_vault).on(:previous_network_transaction_id)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::CardTypeIsInvalid
|
4406
|
+
result.transaction.network_transaction_id.should_not be_nil
|
4374
4407
|
end
|
4375
4408
|
end
|
4376
|
-
|
4377
4409
|
end
|
4378
4410
|
|
4379
4411
|
context "account_type" do
|
@@ -4390,7 +4422,7 @@ describe Braintree::Transaction do
|
|
4390
4422
|
:credit_card => {
|
4391
4423
|
:account_type => "credit",
|
4392
4424
|
}
|
4393
|
-
}
|
4425
|
+
},
|
4394
4426
|
)
|
4395
4427
|
result.success?.should == true
|
4396
4428
|
result.transaction.credit_card_details.account_type.should == "credit"
|
@@ -4409,7 +4441,7 @@ describe Braintree::Transaction do
|
|
4409
4441
|
:credit_card => {
|
4410
4442
|
:account_type => "credit",
|
4411
4443
|
}
|
4412
|
-
}
|
4444
|
+
},
|
4413
4445
|
)
|
4414
4446
|
result.success?.should == true
|
4415
4447
|
result.transaction.credit_card_details.account_type.should == "credit"
|
@@ -4429,7 +4461,7 @@ describe Braintree::Transaction do
|
|
4429
4461
|
:account_type => "debit",
|
4430
4462
|
},
|
4431
4463
|
:submit_for_settlement => true,
|
4432
|
-
}
|
4464
|
+
},
|
4433
4465
|
)
|
4434
4466
|
result.success?.should == true
|
4435
4467
|
result.transaction.credit_card_details.account_type.should == "debit"
|
@@ -4448,7 +4480,7 @@ describe Braintree::Transaction do
|
|
4448
4480
|
:credit_card => {
|
4449
4481
|
:account_type => "debit",
|
4450
4482
|
},
|
4451
|
-
}
|
4483
|
+
},
|
4452
4484
|
)
|
4453
4485
|
result.success?.should == false
|
4454
4486
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeDebitDoesNotSupportAuths
|
@@ -4467,7 +4499,7 @@ describe Braintree::Transaction do
|
|
4467
4499
|
:credit_card => {
|
4468
4500
|
:account_type => "ach",
|
4469
4501
|
},
|
4470
|
-
}
|
4502
|
+
},
|
4471
4503
|
)
|
4472
4504
|
result.success?.should == false
|
4473
4505
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeIsInvalid
|
@@ -4485,7 +4517,7 @@ describe Braintree::Transaction do
|
|
4485
4517
|
:credit_card => {
|
4486
4518
|
:account_type => "credit",
|
4487
4519
|
},
|
4488
|
-
}
|
4520
|
+
},
|
4489
4521
|
)
|
4490
4522
|
result.success?.should == false
|
4491
4523
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeNotSupported
|
@@ -4501,7 +4533,7 @@ describe Braintree::Transaction do
|
|
4501
4533
|
:credit_card => {
|
4502
4534
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4503
4535
|
:expiration_date => "05/2009"
|
4504
|
-
}
|
4536
|
+
},
|
4505
4537
|
)
|
4506
4538
|
transaction.id.should =~ /^\w{6,}$/
|
4507
4539
|
transaction.type.should == "sale"
|
@@ -4519,7 +4551,7 @@ describe Braintree::Transaction do
|
|
4519
4551
|
:credit_card => {
|
4520
4552
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4521
4553
|
:expiration_date => "05/2009"
|
4522
|
-
}
|
4554
|
+
},
|
4523
4555
|
)
|
4524
4556
|
end.to raise_error(Braintree::ValidationsFailed)
|
4525
4557
|
end
|
@@ -4575,7 +4607,7 @@ describe Braintree::Transaction do
|
|
4575
4607
|
:credit_card => {
|
4576
4608
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4577
4609
|
:expiration_date => "05/2009"
|
4578
|
-
}
|
4610
|
+
},
|
4579
4611
|
)
|
4580
4612
|
result = Braintree::Transaction.refund(transaction.id)
|
4581
4613
|
result.success?.should == false
|
@@ -4612,7 +4644,7 @@ describe Braintree::Transaction do
|
|
4612
4644
|
:credit_card => {
|
4613
4645
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4614
4646
|
:expiration_date => "05/2009"
|
4615
|
-
}
|
4647
|
+
},
|
4616
4648
|
)
|
4617
4649
|
result.success?.should == true
|
4618
4650
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -4668,7 +4700,7 @@ describe Braintree::Transaction do
|
|
4668
4700
|
:postal_code => "60103",
|
4669
4701
|
:country_name => "United States of America",
|
4670
4702
|
:shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
|
4671
|
-
}
|
4703
|
+
},
|
4672
4704
|
)
|
4673
4705
|
result.success?.should == true
|
4674
4706
|
transaction = result.transaction
|
@@ -4732,7 +4764,7 @@ describe Braintree::Transaction do
|
|
4732
4764
|
:credit_card => {
|
4733
4765
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4734
4766
|
:expiration_date => "05/2009"
|
4735
|
-
}
|
4767
|
+
},
|
4736
4768
|
)
|
4737
4769
|
result.success?.should == true
|
4738
4770
|
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -4744,7 +4776,7 @@ describe Braintree::Transaction do
|
|
4744
4776
|
:credit_card => {
|
4745
4777
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4746
4778
|
:expiration_date => "05/2009"
|
4747
|
-
}
|
4779
|
+
},
|
4748
4780
|
)
|
4749
4781
|
result.success?.should == true
|
4750
4782
|
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
|
@@ -4763,7 +4795,7 @@ describe Braintree::Transaction do
|
|
4763
4795
|
},
|
4764
4796
|
:options => {
|
4765
4797
|
:store_in_vault => true
|
4766
|
-
}
|
4798
|
+
},
|
4767
4799
|
)
|
4768
4800
|
result.success?.should == true
|
4769
4801
|
transaction = result.transaction
|
@@ -4798,7 +4830,7 @@ describe Braintree::Transaction do
|
|
4798
4830
|
:options => {
|
4799
4831
|
:store_in_vault => true,
|
4800
4832
|
:add_billing_address_to_payment_method => true,
|
4801
|
-
}
|
4833
|
+
},
|
4802
4834
|
)
|
4803
4835
|
result.success?.should == true
|
4804
4836
|
transaction = result.transaction
|
@@ -4843,7 +4875,7 @@ describe Braintree::Transaction do
|
|
4843
4875
|
:options => {
|
4844
4876
|
:store_in_vault => true,
|
4845
4877
|
:store_shipping_address_in_vault => true,
|
4846
|
-
}
|
4878
|
+
},
|
4847
4879
|
)
|
4848
4880
|
result.success?.should == true
|
4849
4881
|
transaction = result.transaction
|
@@ -4869,7 +4901,7 @@ describe Braintree::Transaction do
|
|
4869
4901
|
:number => "5105105105105100",
|
4870
4902
|
:expiration_date => "05/2012"
|
4871
4903
|
},
|
4872
|
-
:options => {
|
4904
|
+
:options => {:store_in_vault => true},
|
4873
4905
|
)
|
4874
4906
|
|
4875
4907
|
result.success?.should == true
|
@@ -4887,7 +4919,7 @@ describe Braintree::Transaction do
|
|
4887
4919
|
},
|
4888
4920
|
:options => {
|
4889
4921
|
:submit_for_settlement => true
|
4890
|
-
}
|
4922
|
+
},
|
4891
4923
|
)
|
4892
4924
|
result.success?.should == true
|
4893
4925
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -4910,7 +4942,7 @@ describe Braintree::Transaction do
|
|
4910
4942
|
},
|
4911
4943
|
:options => {
|
4912
4944
|
:store_in_vault => true
|
4913
|
-
}
|
4945
|
+
},
|
4914
4946
|
)
|
4915
4947
|
result.success?.should == true
|
4916
4948
|
transaction = result.transaction
|
@@ -4925,20 +4957,20 @@ describe Braintree::Transaction do
|
|
4925
4957
|
:credit_card => {
|
4926
4958
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4927
4959
|
:expiration_date => "05/2010"
|
4928
|
-
}
|
4960
|
+
},
|
4929
4961
|
)
|
4930
4962
|
address = Braintree::Address.create!(
|
4931
4963
|
:customer_id => customer.id,
|
4932
|
-
:street_address =>
|
4964
|
+
:street_address => "123 Fake St.",
|
4933
4965
|
)
|
4934
4966
|
result = Braintree::Transaction.sale(
|
4935
4967
|
:amount => "100",
|
4936
4968
|
:customer_id => customer.id,
|
4937
|
-
:shipping_address_id => address.id
|
4969
|
+
:shipping_address_id => address.id,
|
4938
4970
|
)
|
4939
4971
|
result.success?.should == true
|
4940
4972
|
transaction = result.transaction
|
4941
|
-
transaction.shipping_details.street_address.should ==
|
4973
|
+
transaction.shipping_details.street_address.should == "123 Fake St."
|
4942
4974
|
transaction.customer_details.id.should == customer.id
|
4943
4975
|
transaction.shipping_details.id.should == address.id
|
4944
4976
|
end
|
@@ -4955,12 +4987,79 @@ describe Braintree::Transaction do
|
|
4955
4987
|
}
|
4956
4988
|
result = Braintree::Transaction.sale(params[:transaction])
|
4957
4989
|
result.success?.should == false
|
4958
|
-
result.params.should == {:transaction => {:type =>
|
4990
|
+
result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
4959
4991
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
4960
4992
|
end
|
4961
4993
|
|
4994
|
+
it "validates currency_iso_code and creates transaction" do
|
4995
|
+
params = {
|
4996
|
+
:transaction => {
|
4997
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
4998
|
+
:currency_iso_code => "USD",
|
4999
|
+
:credit_card => {
|
5000
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5001
|
+
:expiration_date => "05/2009"
|
5002
|
+
}
|
5003
|
+
}
|
5004
|
+
}
|
5005
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5006
|
+
result.success?.should == true
|
5007
|
+
result.transaction.currency_iso_code == "USD"
|
5008
|
+
end
|
5009
|
+
|
5010
|
+
it "validates currency_iso_code and returns error" do
|
5011
|
+
params = {
|
5012
|
+
:transaction => {
|
5013
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5014
|
+
:currency_iso_code => "CAD",
|
5015
|
+
:credit_card => {
|
5016
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5017
|
+
:expiration_date => "05/2009"
|
5018
|
+
}
|
5019
|
+
}
|
5020
|
+
}
|
5021
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5022
|
+
result.success?.should == false
|
5023
|
+
result.errors.for(:transaction).on(:currency_iso_code)[0].code.should == Braintree::ErrorCodes::Transaction::CurrencyCodeNotSupportedByMerchantAccount
|
5024
|
+
end
|
5025
|
+
|
5026
|
+
it "validates currency_iso_code and creates transaction with specified merchant account" do
|
5027
|
+
params = {
|
5028
|
+
:transaction => {
|
5029
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5030
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
5031
|
+
:currency_iso_code => "USD",
|
5032
|
+
:credit_card => {
|
5033
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5034
|
+
:expiration_date => "05/2009"
|
5035
|
+
}
|
5036
|
+
}
|
5037
|
+
}
|
5038
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5039
|
+
result.success?.should == true
|
5040
|
+
result.transaction.currency_iso_code == "USD"
|
5041
|
+
result.transaction.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
5042
|
+
end
|
5043
|
+
|
5044
|
+
it "validates currency_iso_code and returns error with specified merchant account" do
|
5045
|
+
params = {
|
5046
|
+
:transaction => {
|
5047
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5048
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
5049
|
+
:currency_iso_code => "CAD",
|
5050
|
+
:credit_card => {
|
5051
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5052
|
+
:expiration_date => "05/2009"
|
5053
|
+
}
|
5054
|
+
}
|
5055
|
+
}
|
5056
|
+
result = Braintree::Transaction.sale(params[:transaction])
|
5057
|
+
result.success?.should == false
|
5058
|
+
result.errors.for(:transaction).on(:currency_iso_code)[0].code.should == Braintree::ErrorCodes::Transaction::CurrencyCodeNotSupportedByMerchantAccount
|
5059
|
+
end
|
5060
|
+
|
4962
5061
|
it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
|
4963
|
-
|
5062
|
+
with_advanced_fraud_kount_integration_merchant do
|
4964
5063
|
result = Braintree::Transaction.sale(
|
4965
5064
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
4966
5065
|
:credit_card => {
|
@@ -4969,7 +5068,7 @@ describe Braintree::Transaction do
|
|
4969
5068
|
},
|
4970
5069
|
:options => {
|
4971
5070
|
:skip_advanced_fraud_checking => true
|
4972
|
-
}
|
5071
|
+
},
|
4973
5072
|
)
|
4974
5073
|
result.success?.should == true
|
4975
5074
|
result.transaction.risk_data.should be_nil
|
@@ -5063,7 +5162,7 @@ describe Braintree::Transaction do
|
|
5063
5162
|
:currency_amount => "10.00",
|
5064
5163
|
:currency_iso_code => "USD"
|
5065
5164
|
}
|
5066
|
-
}
|
5165
|
+
},
|
5067
5166
|
)
|
5068
5167
|
result.success?.should == true
|
5069
5168
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5085,7 +5184,7 @@ describe Braintree::Transaction do
|
|
5085
5184
|
:currency_amount => "10.00",
|
5086
5185
|
:currency_iso_code => "USD"
|
5087
5186
|
}
|
5088
|
-
}
|
5187
|
+
},
|
5089
5188
|
)
|
5090
5189
|
result.success?.should == true
|
5091
5190
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5107,7 +5206,7 @@ describe Braintree::Transaction do
|
|
5107
5206
|
:currency_amount => "10.00",
|
5108
5207
|
:currency_iso_code => "USD"
|
5109
5208
|
}
|
5110
|
-
}
|
5209
|
+
},
|
5111
5210
|
)
|
5112
5211
|
result.success?.should == true
|
5113
5212
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5130,7 +5229,7 @@ describe Braintree::Transaction do
|
|
5130
5229
|
:currency_amount => "10.00",
|
5131
5230
|
:currency_iso_code => "USD"
|
5132
5231
|
}
|
5133
|
-
}
|
5232
|
+
},
|
5134
5233
|
)
|
5135
5234
|
result.success?.should == true
|
5136
5235
|
|
@@ -5154,7 +5253,7 @@ describe Braintree::Transaction do
|
|
5154
5253
|
:currency_amount => "10.00",
|
5155
5254
|
:currency_iso_code => "USD"
|
5156
5255
|
}
|
5157
|
-
}
|
5256
|
+
},
|
5158
5257
|
)
|
5159
5258
|
result.success?.should == true
|
5160
5259
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
@@ -5179,7 +5278,7 @@ describe Braintree::Transaction do
|
|
5179
5278
|
:currency_amount => "10.00",
|
5180
5279
|
:currency_iso_code => "USD"
|
5181
5280
|
}
|
5182
|
-
}
|
5281
|
+
},
|
5183
5282
|
)
|
5184
5283
|
result.success?.should == true
|
5185
5284
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
@@ -5199,7 +5298,7 @@ describe Braintree::Transaction do
|
|
5199
5298
|
:credit_card => {
|
5200
5299
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5201
5300
|
:expiration_date => "05/2009"
|
5202
|
-
}
|
5301
|
+
},
|
5203
5302
|
)
|
5204
5303
|
transaction.id.should =~ /^\w{6,}$/
|
5205
5304
|
transaction.type.should == "sale"
|
@@ -5216,7 +5315,7 @@ describe Braintree::Transaction do
|
|
5216
5315
|
:credit_card => {
|
5217
5316
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5218
5317
|
:expiration_date => "05/2009"
|
5219
|
-
}
|
5318
|
+
},
|
5220
5319
|
)
|
5221
5320
|
end.to raise_error(Braintree::ValidationsFailed)
|
5222
5321
|
end
|
@@ -5229,7 +5328,7 @@ describe Braintree::Transaction do
|
|
5229
5328
|
:credit_card => {
|
5230
5329
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5231
5330
|
:expiration_date => "06/2009"
|
5232
|
-
}
|
5331
|
+
},
|
5233
5332
|
)
|
5234
5333
|
result = Braintree::Transaction.submit_for_settlement(transaction.id)
|
5235
5334
|
result.success?.should == true
|
@@ -5241,7 +5340,7 @@ describe Braintree::Transaction do
|
|
5241
5340
|
:credit_card => {
|
5242
5341
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5243
5342
|
:expiration_date => "06/2009"
|
5244
|
-
}
|
5343
|
+
},
|
5245
5344
|
)
|
5246
5345
|
transaction.amount.should == BigDecimal("1000.00")
|
5247
5346
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "999.99")
|
@@ -5257,9 +5356,9 @@ describe Braintree::Transaction do
|
|
5257
5356
|
:credit_card => {
|
5258
5357
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5259
5358
|
:expiration_date => "06/2009"
|
5260
|
-
}
|
5359
|
+
},
|
5261
5360
|
)
|
5262
|
-
options = {
|
5361
|
+
options = {:order_id => "ABC123"}
|
5263
5362
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
5264
5363
|
result.success?.should == true
|
5265
5364
|
result.transaction.order_id.should == "ABC123"
|
@@ -5272,13 +5371,13 @@ describe Braintree::Transaction do
|
|
5272
5371
|
:credit_card => {
|
5273
5372
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5274
5373
|
:expiration_date => "06/2009"
|
5275
|
-
}
|
5374
|
+
},
|
5276
5375
|
)
|
5277
5376
|
|
5278
5377
|
options = {
|
5279
5378
|
:descriptor => {
|
5280
|
-
:name =>
|
5281
|
-
:phone =>
|
5379
|
+
:name => "123*123456789012345678",
|
5380
|
+
:phone => "3334445555",
|
5282
5381
|
:url => "ebay.com"
|
5283
5382
|
}
|
5284
5383
|
}
|
@@ -5286,9 +5385,9 @@ describe Braintree::Transaction do
|
|
5286
5385
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
5287
5386
|
result.success?.should == true
|
5288
5387
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5289
|
-
result.transaction.descriptor.name.should ==
|
5290
|
-
result.transaction.descriptor.phone.should ==
|
5291
|
-
result.transaction.descriptor.url.should ==
|
5388
|
+
result.transaction.descriptor.name.should == "123*123456789012345678"
|
5389
|
+
result.transaction.descriptor.phone.should == "3334445555"
|
5390
|
+
result.transaction.descriptor.url.should == "ebay.com"
|
5292
5391
|
end
|
5293
5392
|
|
5294
5393
|
it "raises an error if an invalid option is passed in" do
|
@@ -5297,10 +5396,10 @@ describe Braintree::Transaction do
|
|
5297
5396
|
:credit_card => {
|
5298
5397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5299
5398
|
:expiration_date => "06/2009"
|
5300
|
-
}
|
5399
|
+
},
|
5301
5400
|
)
|
5302
5401
|
|
5303
|
-
options = {
|
5402
|
+
options = {:order_id => "ABC123", :invalid_option => "i'm invalid"}
|
5304
5403
|
|
5305
5404
|
expect do
|
5306
5405
|
Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
@@ -5310,10 +5409,11 @@ describe Braintree::Transaction do
|
|
5310
5409
|
it "returns an error result if settlement is too large" do
|
5311
5410
|
transaction = Braintree::Transaction.sale!(
|
5312
5411
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5412
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
5313
5413
|
:credit_card => {
|
5314
5414
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5315
5415
|
:expiration_date => "06/2009"
|
5316
|
-
}
|
5416
|
+
},
|
5317
5417
|
)
|
5318
5418
|
transaction.amount.should == BigDecimal("1000.00")
|
5319
5419
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "1000.01")
|
@@ -5328,7 +5428,7 @@ describe Braintree::Transaction do
|
|
5328
5428
|
:credit_card => {
|
5329
5429
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5330
5430
|
:expiration_date => "06/2009"
|
5331
|
-
}
|
5431
|
+
},
|
5332
5432
|
).transaction
|
5333
5433
|
result = Braintree::Transaction.submit_for_settlement(transaction.id)
|
5334
5434
|
result.success?.should == false
|
@@ -5345,7 +5445,7 @@ describe Braintree::Transaction do
|
|
5345
5445
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5346
5446
|
:expiration_date => "06/2009"
|
5347
5447
|
},
|
5348
|
-
:service_fee_amount => "1.00"
|
5448
|
+
:service_fee_amount => "1.00",
|
5349
5449
|
).transaction
|
5350
5450
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
|
5351
5451
|
result.success?.should == false
|
@@ -5368,7 +5468,7 @@ describe Braintree::Transaction do
|
|
5368
5468
|
:currency_amount => "10.00",
|
5369
5469
|
:currency_iso_code => "USD"
|
5370
5470
|
}
|
5371
|
-
}
|
5471
|
+
},
|
5372
5472
|
)
|
5373
5473
|
result.success?.should == true
|
5374
5474
|
|
@@ -5392,7 +5492,7 @@ describe Braintree::Transaction do
|
|
5392
5492
|
:currency_amount => "10.00",
|
5393
5493
|
:currency_iso_code => "USD"
|
5394
5494
|
}
|
5395
|
-
}
|
5495
|
+
},
|
5396
5496
|
)
|
5397
5497
|
result.success?.should == true
|
5398
5498
|
|
@@ -5412,7 +5512,7 @@ describe Braintree::Transaction do
|
|
5412
5512
|
:discount_amount => "12.00",
|
5413
5513
|
:tax_amount => "0",
|
5414
5514
|
},
|
5415
|
-
]
|
5515
|
+
],
|
5416
5516
|
)
|
5417
5517
|
result.success?.should == true
|
5418
5518
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5426,9 +5526,9 @@ describe Braintree::Transaction do
|
|
5426
5526
|
:credit_card => {
|
5427
5527
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5428
5528
|
:expiration_date => "06/2009"
|
5429
|
-
}
|
5529
|
+
},
|
5430
5530
|
)
|
5431
|
-
options = {
|
5531
|
+
options = {:order_id => "ABC123"}
|
5432
5532
|
transaction = Braintree::Transaction.submit_for_settlement!(original_transaction.id, "0.01", options)
|
5433
5533
|
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5434
5534
|
transaction.id.should == original_transaction.id
|
@@ -5438,10 +5538,11 @@ describe Braintree::Transaction do
|
|
5438
5538
|
it "raises a ValidationsFailed if unsuccessful" do
|
5439
5539
|
transaction = Braintree::Transaction.sale!(
|
5440
5540
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5541
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
5441
5542
|
:credit_card => {
|
5442
5543
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5443
5544
|
:expiration_date => "06/2009"
|
5444
|
-
}
|
5545
|
+
},
|
5445
5546
|
)
|
5446
5547
|
transaction.amount.should == BigDecimal("1000.00")
|
5447
5548
|
expect do
|
@@ -5457,18 +5558,18 @@ describe Braintree::Transaction do
|
|
5457
5558
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5458
5559
|
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
5459
5560
|
:descriptor => {
|
5460
|
-
:name =>
|
5461
|
-
:phone =>
|
5561
|
+
:name => "123*123456789012345678",
|
5562
|
+
:phone => "3334445555",
|
5462
5563
|
:url => "ebay.com"
|
5463
5564
|
},
|
5464
|
-
:order_id =>
|
5565
|
+
:order_id => "123",
|
5465
5566
|
:credit_card => {
|
5466
5567
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5467
5568
|
:expiration_date => "06/2009"
|
5468
5569
|
},
|
5469
5570
|
:options => {
|
5470
5571
|
:submit_for_settlement => true
|
5471
|
-
}
|
5572
|
+
},
|
5472
5573
|
)
|
5473
5574
|
end
|
5474
5575
|
|
@@ -5476,16 +5577,16 @@ describe Braintree::Transaction do
|
|
5476
5577
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5477
5578
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5478
5579
|
:descriptor => {
|
5479
|
-
:name =>
|
5480
|
-
:phone =>
|
5580
|
+
:name => "456*123456789012345678",
|
5581
|
+
:phone => "3334445555",
|
5481
5582
|
:url => "ebay.com",
|
5482
5583
|
},
|
5483
|
-
:order_id =>
|
5584
|
+
:order_id => "456"
|
5484
5585
|
})
|
5485
5586
|
result.success?.should == true
|
5486
5587
|
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize) - 1
|
5487
|
-
result.transaction.order_id.should ==
|
5488
|
-
result.transaction.descriptor.name.should ==
|
5588
|
+
result.transaction.order_id.should == "456"
|
5589
|
+
result.transaction.descriptor.name.should == "456*123456789012345678"
|
5489
5590
|
end
|
5490
5591
|
|
5491
5592
|
it "raises an error when a key is invalid" do
|
@@ -5493,11 +5594,11 @@ describe Braintree::Transaction do
|
|
5493
5594
|
Braintree::Transaction.update_details(transaction.id, {
|
5494
5595
|
:invalid_key => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5495
5596
|
:descriptor => {
|
5496
|
-
:name =>
|
5497
|
-
:phone =>
|
5597
|
+
:name => "456*123456789012345678",
|
5598
|
+
:phone => "3334445555",
|
5498
5599
|
:url => "ebay.com",
|
5499
5600
|
},
|
5500
|
-
:order_id =>
|
5601
|
+
:order_id => "456"
|
5501
5602
|
})
|
5502
5603
|
end.to raise_error(ArgumentError)
|
5503
5604
|
end
|
@@ -5507,11 +5608,11 @@ describe Braintree::Transaction do
|
|
5507
5608
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5508
5609
|
:amount => "10000",
|
5509
5610
|
:descriptor => {
|
5510
|
-
:name =>
|
5511
|
-
:phone =>
|
5611
|
+
:name => "456*123456789012345678",
|
5612
|
+
:phone => "3334445555",
|
5512
5613
|
:url => "ebay.com",
|
5513
5614
|
},
|
5514
|
-
:order_id =>
|
5615
|
+
:order_id => "456"
|
5515
5616
|
})
|
5516
5617
|
result.success?.should == false
|
5517
5618
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
|
@@ -5521,11 +5622,11 @@ describe Braintree::Transaction do
|
|
5521
5622
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5522
5623
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5523
5624
|
:descriptor => {
|
5524
|
-
:name =>
|
5525
|
-
:phone =>
|
5526
|
-
:url =>
|
5625
|
+
:name => "invalid descriptor name",
|
5626
|
+
:phone => "invalid phone",
|
5627
|
+
:url => "12345678901234"
|
5527
5628
|
},
|
5528
|
-
:order_id =>
|
5629
|
+
:order_id => "456"
|
5529
5630
|
})
|
5530
5631
|
result.success?.should == false
|
5531
5632
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -5537,11 +5638,11 @@ describe Braintree::Transaction do
|
|
5537
5638
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5538
5639
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5539
5640
|
:descriptor => {
|
5540
|
-
:name =>
|
5541
|
-
:phone =>
|
5641
|
+
:name => "456*123456789012345678",
|
5642
|
+
:phone => "3334445555",
|
5542
5643
|
:url => "ebay.com",
|
5543
5644
|
},
|
5544
|
-
:order_id =>
|
5645
|
+
:order_id => "x" * 256
|
5545
5646
|
})
|
5546
5647
|
result.success?.should == false
|
5547
5648
|
result.errors.for(:transaction).on(:order_id)[0].code.should == Braintree::ErrorCodes::Transaction::OrderIdIsTooLong
|
@@ -5552,27 +5653,27 @@ describe Braintree::Transaction do
|
|
5552
5653
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5553
5654
|
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5554
5655
|
:descriptor => {
|
5555
|
-
:name =>
|
5556
|
-
:phone =>
|
5656
|
+
:name => "123*123456789012345678",
|
5657
|
+
:phone => "3334445555",
|
5557
5658
|
:url => "ebay.com"
|
5558
5659
|
},
|
5559
|
-
:order_id =>
|
5660
|
+
:order_id => "123",
|
5560
5661
|
:credit_card => {
|
5561
5662
|
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5562
5663
|
:expiration_date => "05/2009"
|
5563
5664
|
},
|
5564
5665
|
:options => {
|
5565
5666
|
:submit_for_settlement => true
|
5566
|
-
}
|
5667
|
+
},
|
5567
5668
|
)
|
5568
5669
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5569
5670
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5570
5671
|
:descriptor => {
|
5571
|
-
:name =>
|
5572
|
-
:phone =>
|
5672
|
+
:name => "456*123456789012345678",
|
5673
|
+
:phone => "3334445555",
|
5573
5674
|
:url => "ebay.com",
|
5574
5675
|
},
|
5575
|
-
:order_id =>
|
5676
|
+
:order_id => "456"
|
5576
5677
|
})
|
5577
5678
|
result.success?.should == false
|
5578
5679
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportUpdatingTransactionDetails
|
@@ -5586,24 +5687,24 @@ describe Braintree::Transaction do
|
|
5586
5687
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5587
5688
|
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
5588
5689
|
:descriptor => {
|
5589
|
-
:name =>
|
5590
|
-
:phone =>
|
5690
|
+
:name => "123*123456789012345678",
|
5691
|
+
:phone => "3334445555",
|
5591
5692
|
:url => "ebay.com"
|
5592
5693
|
},
|
5593
|
-
:order_id =>
|
5694
|
+
:order_id => "123",
|
5594
5695
|
:credit_card => {
|
5595
5696
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5596
5697
|
:expiration_date => "06/2009"
|
5597
|
-
}
|
5698
|
+
},
|
5598
5699
|
)
|
5599
5700
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5600
5701
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5601
5702
|
:descriptor => {
|
5602
|
-
:name =>
|
5603
|
-
:phone =>
|
5703
|
+
:name => "456*123456789012345678",
|
5704
|
+
:phone => "3334445555",
|
5604
5705
|
:url => "ebay.com",
|
5605
5706
|
},
|
5606
|
-
:order_id =>
|
5707
|
+
:order_id => "456"
|
5607
5708
|
})
|
5608
5709
|
result.success?.should == false
|
5609
5710
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotUpdateTransactionDetailsNotSubmittedForSettlement
|
@@ -5620,7 +5721,7 @@ describe Braintree::Transaction do
|
|
5620
5721
|
:credit_card => {
|
5621
5722
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5622
5723
|
:expiration_date => "06/2009"
|
5623
|
-
}
|
5724
|
+
},
|
5624
5725
|
)
|
5625
5726
|
|
5626
5727
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5655,7 +5756,7 @@ describe Braintree::Transaction do
|
|
5655
5756
|
:credit_card => {
|
5656
5757
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5657
5758
|
:expiration_date => "05/2009"
|
5658
|
-
}
|
5759
|
+
},
|
5659
5760
|
)
|
5660
5761
|
|
5661
5762
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => 1234)
|
@@ -5671,7 +5772,7 @@ describe Braintree::Transaction do
|
|
5671
5772
|
:credit_card => {
|
5672
5773
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5673
5774
|
:expiration_date => "05/2009"
|
5674
|
-
}
|
5775
|
+
},
|
5675
5776
|
)
|
5676
5777
|
|
5677
5778
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => "1"*256)
|
@@ -5686,13 +5787,13 @@ describe Braintree::Transaction do
|
|
5686
5787
|
:credit_card => {
|
5687
5788
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5688
5789
|
:expiration_date => "05/2009"
|
5689
|
-
}
|
5790
|
+
},
|
5690
5791
|
)
|
5691
5792
|
|
5692
5793
|
result = Braintree::Transaction.submit_for_partial_settlement(
|
5693
5794
|
authorized_transaction.id,
|
5694
5795
|
100,
|
5695
|
-
:descriptor => {
|
5796
|
+
:descriptor => {:name => "123*123456789012345678", :phone => "5555551234", :url => "url.com"},
|
5696
5797
|
)
|
5697
5798
|
result.success?.should == true
|
5698
5799
|
partial_settlement_transaction = result.transaction
|
@@ -5708,7 +5809,7 @@ describe Braintree::Transaction do
|
|
5708
5809
|
:credit_card => {
|
5709
5810
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5710
5811
|
:expiration_date => "05/2009"
|
5711
|
-
}
|
5812
|
+
},
|
5712
5813
|
)
|
5713
5814
|
|
5714
5815
|
result = Braintree::Transaction.submit_for_partial_settlement(
|
@@ -5716,9 +5817,9 @@ describe Braintree::Transaction do
|
|
5716
5817
|
100,
|
5717
5818
|
:descriptor => {
|
5718
5819
|
:name => "invalid_format",
|
5719
|
-
:phone =>
|
5720
|
-
:url =>
|
5721
|
-
}
|
5820
|
+
:phone => "%bad4445555",
|
5821
|
+
:url => "12345678901234"
|
5822
|
+
},
|
5722
5823
|
)
|
5723
5824
|
result.success?.should == false
|
5724
5825
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -5733,7 +5834,7 @@ describe Braintree::Transaction do
|
|
5733
5834
|
:credit_card => {
|
5734
5835
|
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5735
5836
|
:expiration_date => "05/2009"
|
5736
|
-
}
|
5837
|
+
},
|
5737
5838
|
)
|
5738
5839
|
|
5739
5840
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5745,7 +5846,7 @@ describe Braintree::Transaction do
|
|
5745
5846
|
authorized_transaction = Braintree::Transaction.sale!(
|
5746
5847
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5747
5848
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
5748
|
-
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
|
5849
|
+
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
5749
5850
|
)
|
5750
5851
|
|
5751
5852
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5760,7 +5861,7 @@ describe Braintree::Transaction do
|
|
5760
5861
|
:credit_card => {
|
5761
5862
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5762
5863
|
:expiration_date => "06/2009"
|
5763
|
-
}
|
5864
|
+
},
|
5764
5865
|
)
|
5765
5866
|
|
5766
5867
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5778,7 +5879,7 @@ describe Braintree::Transaction do
|
|
5778
5879
|
:credit_card => {
|
5779
5880
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5780
5881
|
:expiration_date => "06/2009"
|
5781
|
-
}
|
5882
|
+
},
|
5782
5883
|
)
|
5783
5884
|
|
5784
5885
|
result = Braintree::Transaction.void(authorized_transaction.id)
|
@@ -5797,9 +5898,9 @@ describe Braintree::Transaction do
|
|
5797
5898
|
:credit_card => {
|
5798
5899
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5799
5900
|
:expiration_date => "06/2009"
|
5800
|
-
}
|
5901
|
+
},
|
5801
5902
|
)
|
5802
|
-
options = {
|
5903
|
+
options = {:order_id => "ABC123"}
|
5803
5904
|
transaction = Braintree::Transaction.submit_for_partial_settlement!(original_transaction.id, "0.01", options)
|
5804
5905
|
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5805
5906
|
transaction.order_id.should == options[:order_id]
|
@@ -5811,7 +5912,7 @@ describe Braintree::Transaction do
|
|
5811
5912
|
:credit_card => {
|
5812
5913
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5813
5914
|
:expiration_date => "06/2009"
|
5814
|
-
}
|
5915
|
+
},
|
5815
5916
|
)
|
5816
5917
|
transaction.amount.should == BigDecimal("1000.00")
|
5817
5918
|
expect do
|
@@ -5836,7 +5937,7 @@ describe Braintree::Transaction do
|
|
5836
5937
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5837
5938
|
:expiration_date => "05/2009"
|
5838
5939
|
},
|
5839
|
-
:service_fee_amount =>
|
5940
|
+
:service_fee_amount => "1.00",
|
5840
5941
|
)
|
5841
5942
|
|
5842
5943
|
transaction.escrow_status.should be_nil
|
@@ -5862,7 +5963,7 @@ describe Braintree::Transaction do
|
|
5862
5963
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5863
5964
|
:expiration_date => "05/2009"
|
5864
5965
|
},
|
5865
|
-
:service_fee_amount =>
|
5966
|
+
:service_fee_amount => "1.00",
|
5866
5967
|
)
|
5867
5968
|
|
5868
5969
|
transaction.escrow_status.should be_nil
|
@@ -5922,7 +6023,7 @@ describe Braintree::Transaction do
|
|
5922
6023
|
:credit_card => {
|
5923
6024
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5924
6025
|
:expiration_date => "05/2009"
|
5925
|
-
}
|
6026
|
+
},
|
5926
6027
|
)
|
5927
6028
|
result.success?.should == true
|
5928
6029
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -5945,7 +6046,7 @@ describe Braintree::Transaction do
|
|
5945
6046
|
}
|
5946
6047
|
result = Braintree::Transaction.credit(params[:transaction])
|
5947
6048
|
result.success?.should == false
|
5948
|
-
result.params.should == {:transaction => {:type =>
|
6049
|
+
result.params.should == {:transaction => {:type => "credit", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
5949
6050
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
5950
6051
|
end
|
5951
6052
|
|
@@ -5956,7 +6057,7 @@ describe Braintree::Transaction do
|
|
5956
6057
|
:credit_card => {
|
5957
6058
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5958
6059
|
:expiration_date => "05/2009"
|
5959
|
-
}
|
6060
|
+
},
|
5960
6061
|
)
|
5961
6062
|
result.success?.should == true
|
5962
6063
|
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -5968,7 +6069,7 @@ describe Braintree::Transaction do
|
|
5968
6069
|
:credit_card => {
|
5969
6070
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5970
6071
|
:expiration_date => "05/2009"
|
5971
|
-
}
|
6072
|
+
},
|
5972
6073
|
)
|
5973
6074
|
result.success?.should == true
|
5974
6075
|
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
|
@@ -5998,7 +6099,7 @@ describe Braintree::Transaction do
|
|
5998
6099
|
:credit_card => {
|
5999
6100
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6000
6101
|
:expiration_date => "05/2009"
|
6001
|
-
}
|
6102
|
+
},
|
6002
6103
|
)
|
6003
6104
|
transaction.id.should =~ /^\w{6,}$/
|
6004
6105
|
transaction.type.should == "credit"
|
@@ -6015,7 +6116,7 @@ describe Braintree::Transaction do
|
|
6015
6116
|
:credit_card => {
|
6016
6117
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6017
6118
|
:expiration_date => "05/2009"
|
6018
|
-
}
|
6119
|
+
},
|
6019
6120
|
)
|
6020
6121
|
end.to raise_error(Braintree::ValidationsFailed)
|
6021
6122
|
end
|
@@ -6029,7 +6130,7 @@ describe Braintree::Transaction do
|
|
6029
6130
|
:credit_card => {
|
6030
6131
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6031
6132
|
:expiration_date => "05/2009"
|
6032
|
-
}
|
6133
|
+
},
|
6033
6134
|
)
|
6034
6135
|
result.success?.should == true
|
6035
6136
|
created_transaction = result.transaction
|
@@ -6046,7 +6147,7 @@ describe Braintree::Transaction do
|
|
6046
6147
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6047
6148
|
:expiration_date => "05/2009"
|
6048
6149
|
},
|
6049
|
-
:options => {
|
6150
|
+
:options => {:store_in_vault => true},
|
6050
6151
|
)
|
6051
6152
|
result.success?.should == true
|
6052
6153
|
created_transaction = result.transaction
|
@@ -6091,7 +6192,7 @@ describe Braintree::Transaction do
|
|
6091
6192
|
:credit_card => {
|
6092
6193
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6093
6194
|
:expiration_date => "05/2009"
|
6094
|
-
}
|
6195
|
+
},
|
6095
6196
|
)
|
6096
6197
|
result.success?.should == true
|
6097
6198
|
created_transaction = result.transaction
|
@@ -6141,7 +6242,7 @@ describe Braintree::Transaction do
|
|
6141
6242
|
:credit_card => {
|
6142
6243
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6143
6244
|
:expiration_date => "05/2009"
|
6144
|
-
}
|
6245
|
+
},
|
6145
6246
|
)
|
6146
6247
|
result.success?.should == true
|
6147
6248
|
created_transaction = result.transaction
|
@@ -6154,15 +6255,21 @@ describe Braintree::Transaction do
|
|
6154
6255
|
it "returns all the three_d_secure_info" do
|
6155
6256
|
transaction = Braintree::Transaction.find("threedsecuredtransaction")
|
6156
6257
|
|
6258
|
+
expect(transaction.three_d_secure_info.authentication).to have_key(:trans_status)
|
6259
|
+
expect(transaction.three_d_secure_info.authentication).to have_key(:trans_status_reason)
|
6260
|
+
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status)
|
6261
|
+
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status_reason)
|
6262
|
+
transaction.three_d_secure_info.cavv.should == "somebase64value"
|
6263
|
+
transaction.three_d_secure_info.ds_transaction_id.should == "dstxnid"
|
6264
|
+
transaction.three_d_secure_info.eci_flag.should == "07"
|
6157
6265
|
transaction.three_d_secure_info.enrolled.should == "Y"
|
6158
|
-
transaction.three_d_secure_info.should
|
6266
|
+
transaction.three_d_secure_info.pares_status.should == "Y"
|
6159
6267
|
transaction.three_d_secure_info.should be_liability_shift_possible
|
6268
|
+
transaction.three_d_secure_info.should be_liability_shifted
|
6160
6269
|
transaction.three_d_secure_info.status.should == "authenticate_successful"
|
6161
|
-
transaction.three_d_secure_info.
|
6162
|
-
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6163
|
-
transaction.three_d_secure_info.eci_flag.should == "07"
|
6270
|
+
expect(transaction.three_d_secure_info.three_d_secure_authentication_id).to be
|
6164
6271
|
transaction.three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
6165
|
-
transaction.three_d_secure_info.
|
6272
|
+
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6166
6273
|
end
|
6167
6274
|
|
6168
6275
|
it "is nil if the transaction wasn't 3d secured" do
|
@@ -6204,7 +6311,7 @@ describe Braintree::Transaction do
|
|
6204
6311
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6205
6312
|
:expiration_date => "12/12",
|
6206
6313
|
},
|
6207
|
-
:service_fee_amount => "10.00"
|
6314
|
+
:service_fee_amount => "10.00",
|
6208
6315
|
)
|
6209
6316
|
|
6210
6317
|
result.transaction.escrow_status.should be_nil
|
@@ -6221,7 +6328,7 @@ describe Braintree::Transaction do
|
|
6221
6328
|
:credit_card => {
|
6222
6329
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6223
6330
|
:expiration_date => "05/2009"
|
6224
|
-
}
|
6331
|
+
},
|
6225
6332
|
)
|
6226
6333
|
|
6227
6334
|
result = Braintree::Transaction.hold_in_escrow(transaction.id)
|
@@ -6239,7 +6346,7 @@ describe Braintree::Transaction do
|
|
6239
6346
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6240
6347
|
:expiration_date => "12/12",
|
6241
6348
|
},
|
6242
|
-
:service_fee_amount => "10.00"
|
6349
|
+
:service_fee_amount => "10.00",
|
6243
6350
|
)
|
6244
6351
|
|
6245
6352
|
result.transaction.escrow_status.should be_nil
|
@@ -6255,7 +6362,7 @@ describe Braintree::Transaction do
|
|
6255
6362
|
:credit_card => {
|
6256
6363
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6257
6364
|
:expiration_date => "05/2009"
|
6258
|
-
}
|
6365
|
+
},
|
6259
6366
|
)
|
6260
6367
|
|
6261
6368
|
expect do
|
@@ -6271,7 +6378,7 @@ describe Braintree::Transaction do
|
|
6271
6378
|
:credit_card => {
|
6272
6379
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6273
6380
|
:expiration_date => "05/2009"
|
6274
|
-
}
|
6381
|
+
},
|
6275
6382
|
)
|
6276
6383
|
result = Braintree::Transaction.void(transaction.id)
|
6277
6384
|
result.success?.should == true
|
@@ -6285,7 +6392,7 @@ describe Braintree::Transaction do
|
|
6285
6392
|
:credit_card => {
|
6286
6393
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6287
6394
|
:expiration_date => "05/2009"
|
6288
|
-
}
|
6395
|
+
},
|
6289
6396
|
).transaction
|
6290
6397
|
result = Braintree::Transaction.void(transaction.id)
|
6291
6398
|
result.success?.should == false
|
@@ -6300,7 +6407,7 @@ describe Braintree::Transaction do
|
|
6300
6407
|
:credit_card => {
|
6301
6408
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6302
6409
|
:expiration_date => "05/2009"
|
6303
|
-
}
|
6410
|
+
},
|
6304
6411
|
)
|
6305
6412
|
returned_transaction = Braintree::Transaction.void!(transaction.id)
|
6306
6413
|
returned_transaction.should == transaction
|
@@ -6313,7 +6420,7 @@ describe Braintree::Transaction do
|
|
6313
6420
|
:credit_card => {
|
6314
6421
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6315
6422
|
:expiration_date => "05/2009"
|
6316
|
-
}
|
6423
|
+
},
|
6317
6424
|
).transaction
|
6318
6425
|
expect do
|
6319
6426
|
Braintree::Transaction.void!(transaction.id)
|
@@ -6328,7 +6435,7 @@ describe Braintree::Transaction do
|
|
6328
6435
|
:credit_card => {
|
6329
6436
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6330
6437
|
:expiration_date => "05/2009"
|
6331
|
-
}
|
6438
|
+
},
|
6332
6439
|
)
|
6333
6440
|
result = Braintree::Transaction.submit_for_settlement!(transaction.id)
|
6334
6441
|
result.status_history.size.should == 2
|
@@ -6386,7 +6493,7 @@ describe Braintree::Transaction do
|
|
6386
6493
|
:credit_card => {
|
6387
6494
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6388
6495
|
:expiration_date => "05/2010"
|
6389
|
-
}
|
6496
|
+
},
|
6390
6497
|
)
|
6391
6498
|
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, {:amount => "100.00"}).transaction
|
6392
6499
|
transaction.vault_credit_card.should == customer.credit_cards[0]
|
@@ -6399,7 +6506,7 @@ describe Braintree::Transaction do
|
|
6399
6506
|
:credit_card => {
|
6400
6507
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6401
6508
|
:expiration_date => "05/2010"
|
6402
|
-
}
|
6509
|
+
},
|
6403
6510
|
)
|
6404
6511
|
transaction.vault_credit_card.should == nil
|
6405
6512
|
end
|
@@ -6411,7 +6518,7 @@ describe Braintree::Transaction do
|
|
6411
6518
|
:credit_card => {
|
6412
6519
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6413
6520
|
:expiration_date => "05/2010"
|
6414
|
-
}
|
6521
|
+
},
|
6415
6522
|
)
|
6416
6523
|
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00").transaction
|
6417
6524
|
transaction.vault_customer.should == customer
|
@@ -6424,7 +6531,7 @@ describe Braintree::Transaction do
|
|
6424
6531
|
:credit_card => {
|
6425
6532
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6426
6533
|
:expiration_date => "05/2010"
|
6427
|
-
}
|
6534
|
+
},
|
6428
6535
|
)
|
6429
6536
|
transaction.vault_customer.should == nil
|
6430
6537
|
end
|
@@ -6439,7 +6546,7 @@ describe Braintree::Transaction do
|
|
6439
6546
|
},
|
6440
6547
|
:options => {
|
6441
6548
|
:submit_for_settlement => true
|
6442
|
-
}
|
6549
|
+
},
|
6443
6550
|
)
|
6444
6551
|
|
6445
6552
|
config = Braintree::Configuration.instantiate
|
@@ -6453,7 +6560,7 @@ describe Braintree::Transaction do
|
|
6453
6560
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
6454
6561
|
:options => {
|
6455
6562
|
:submit_for_settlement => true
|
6456
|
-
}
|
6563
|
+
},
|
6457
6564
|
)
|
6458
6565
|
|
6459
6566
|
config = Braintree::Configuration.instantiate
|
@@ -6469,8 +6576,8 @@ describe Braintree::Transaction do
|
|
6469
6576
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6470
6577
|
:expiration_date => "05/2009"
|
6471
6578
|
},
|
6472
|
-
:service_fee_amount =>
|
6473
|
-
:options => {
|
6579
|
+
:service_fee_amount => "1.00",
|
6580
|
+
:options => {:hold_in_escrow => true},
|
6474
6581
|
)
|
6475
6582
|
|
6476
6583
|
config = Braintree::Configuration.instantiate
|
@@ -6484,7 +6591,7 @@ describe Braintree::Transaction do
|
|
6484
6591
|
it "can create a transaction with venmo_sdk_payment_method_code" do
|
6485
6592
|
result = Braintree::Transaction.sale(
|
6486
6593
|
:amount => "10.00",
|
6487
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa)
|
6594
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa),
|
6488
6595
|
)
|
6489
6596
|
result.success?.should == true
|
6490
6597
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6493,7 +6600,7 @@ describe Braintree::Transaction do
|
|
6493
6600
|
it "errors when an invalid payment method code is passed" do
|
6494
6601
|
result = Braintree::Transaction.sale(
|
6495
6602
|
:amount => "10.00",
|
6496
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
|
6603
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
|
6497
6604
|
)
|
6498
6605
|
result.success?.should == false
|
6499
6606
|
result.message.should include("Invalid VenmoSDK payment method code")
|
@@ -6511,7 +6618,7 @@ describe Braintree::Transaction do
|
|
6511
6618
|
},
|
6512
6619
|
:options => {
|
6513
6620
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
6514
|
-
}
|
6621
|
+
},
|
6515
6622
|
)
|
6516
6623
|
result.success?.should == true
|
6517
6624
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6526,7 +6633,7 @@ describe Braintree::Transaction do
|
|
6526
6633
|
},
|
6527
6634
|
:options => {
|
6528
6635
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
6529
|
-
}
|
6636
|
+
},
|
6530
6637
|
)
|
6531
6638
|
result.success?.should == true
|
6532
6639
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6538,7 +6645,7 @@ describe Braintree::Transaction do
|
|
6538
6645
|
it "can create a transaction for a paypal account" do
|
6539
6646
|
result = Braintree::Transaction.sale(
|
6540
6647
|
:amount => "10.00",
|
6541
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
6648
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6542
6649
|
)
|
6543
6650
|
result.success?.should == true
|
6544
6651
|
result.transaction.paypal_details.payer_email.should == "payer@example.com"
|
@@ -6553,7 +6660,7 @@ describe Braintree::Transaction do
|
|
6553
6660
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6554
6661
|
:options => {
|
6555
6662
|
:store_in_vault => true
|
6556
|
-
}
|
6663
|
+
},
|
6557
6664
|
)
|
6558
6665
|
result.success?.should == true
|
6559
6666
|
result.transaction.paypal_details.token.should_not be_nil
|
@@ -6566,7 +6673,7 @@ describe Braintree::Transaction do
|
|
6566
6673
|
customer = Braintree::Customer.create!
|
6567
6674
|
result = Braintree::PaymentMethod.create(
|
6568
6675
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6569
|
-
:customer_id => customer.id
|
6676
|
+
:customer_id => customer.id,
|
6570
6677
|
)
|
6571
6678
|
|
6572
6679
|
result.should be_success
|
@@ -6576,7 +6683,7 @@ describe Braintree::Transaction do
|
|
6576
6683
|
result = Braintree::Transaction.sale(
|
6577
6684
|
:amount => "100",
|
6578
6685
|
:customer_id => customer.id,
|
6579
|
-
:payment_method_token => payment_method_token
|
6686
|
+
:payment_method_token => payment_method_token,
|
6580
6687
|
)
|
6581
6688
|
|
6582
6689
|
result.should be_success
|
@@ -6591,7 +6698,7 @@ describe Braintree::Transaction do
|
|
6591
6698
|
nonce = nonce_for_paypal_account(:token => "TOKEN")
|
6592
6699
|
result = Braintree::Transaction.sale(
|
6593
6700
|
:amount => "10.00",
|
6594
|
-
:payment_method_nonce => nonce
|
6701
|
+
:payment_method_nonce => nonce,
|
6595
6702
|
)
|
6596
6703
|
result.should_not be_success
|
6597
6704
|
result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount
|
@@ -6606,7 +6713,7 @@ describe Braintree::Transaction do
|
|
6606
6713
|
:public_key => "oauth_app_partner_user_public_key",
|
6607
6714
|
:private_key => "oauth_app_partner_user_private_key",
|
6608
6715
|
:environment => Braintree::Configuration.environment,
|
6609
|
-
:logger => Logger.new("/dev/null")
|
6716
|
+
:logger => Logger.new("/dev/null"),
|
6610
6717
|
)
|
6611
6718
|
@customer = @partner_merchant_gateway.customer.create(
|
6612
6719
|
:first_name => "Joe",
|
@@ -6615,12 +6722,12 @@ describe Braintree::Transaction do
|
|
6615
6722
|
:email => "joe@example.com",
|
6616
6723
|
:phone => "312.555.1234",
|
6617
6724
|
:fax => "614.555.5678",
|
6618
|
-
:website => "www.example.com"
|
6725
|
+
:website => "www.example.com",
|
6619
6726
|
).customer
|
6620
6727
|
@address = @partner_merchant_gateway.address.create(
|
6621
6728
|
:customer_id => @customer.id,
|
6622
6729
|
:first_name => "Testy",
|
6623
|
-
:last_name => "McTesterson"
|
6730
|
+
:last_name => "McTesterson",
|
6624
6731
|
).address
|
6625
6732
|
@credit_card = @partner_merchant_gateway.credit_card.create(
|
6626
6733
|
:customer_id => @customer.id,
|
@@ -6631,13 +6738,13 @@ describe Braintree::Transaction do
|
|
6631
6738
|
:first_name => "Adam",
|
6632
6739
|
:last_name => "Davis",
|
6633
6740
|
:postal_code => "95131"
|
6634
|
-
}
|
6741
|
+
},
|
6635
6742
|
).credit_card
|
6636
6743
|
|
6637
6744
|
oauth_gateway = Braintree::Gateway.new(
|
6638
6745
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
6639
6746
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
6640
|
-
:logger => Logger.new("/dev/null")
|
6747
|
+
:logger => Logger.new("/dev/null"),
|
6641
6748
|
)
|
6642
6749
|
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
6643
6750
|
:merchant_public_id => "integration_merchant_id",
|
@@ -6646,7 +6753,7 @@ describe Braintree::Transaction do
|
|
6646
6753
|
|
6647
6754
|
@granting_gateway = Braintree::Gateway.new(
|
6648
6755
|
:access_token => access_token,
|
6649
|
-
:logger => Logger.new("/dev/null")
|
6756
|
+
:logger => Logger.new("/dev/null"),
|
6650
6757
|
)
|
6651
6758
|
|
6652
6759
|
end
|
@@ -6656,7 +6763,7 @@ describe Braintree::Transaction do
|
|
6656
6763
|
|
6657
6764
|
result = Braintree::Transaction.sale(
|
6658
6765
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
6659
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6766
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6660
6767
|
)
|
6661
6768
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6662
6769
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6672,7 +6779,7 @@ describe Braintree::Transaction do
|
|
6672
6779
|
|
6673
6780
|
result = Braintree::Transaction.sale(
|
6674
6781
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
6675
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6782
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6676
6783
|
)
|
6677
6784
|
|
6678
6785
|
result.transaction.billing_details.postal_code == "95131"
|
@@ -6684,7 +6791,7 @@ describe Braintree::Transaction do
|
|
6684
6791
|
:shared_customer_id => @customer.id,
|
6685
6792
|
:shared_shipping_address_id => @address.id,
|
6686
6793
|
:shared_billing_address_id => @address.id,
|
6687
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6794
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6688
6795
|
)
|
6689
6796
|
result.success?.should == true
|
6690
6797
|
result.transaction.shipping_details.first_name.should == @address.first_name
|
@@ -6694,7 +6801,7 @@ describe Braintree::Transaction do
|
|
6694
6801
|
it "facilitated details are returned on transaction created via a shared_payment_method_token" do
|
6695
6802
|
result = @granting_gateway.transaction.sale(
|
6696
6803
|
:shared_payment_method_token => @credit_card.token,
|
6697
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6804
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6698
6805
|
)
|
6699
6806
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6700
6807
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6706,12 +6813,12 @@ describe Braintree::Transaction do
|
|
6706
6813
|
|
6707
6814
|
it "facilitated details are returned on transaction created via a shared_payment_method_nonce" do
|
6708
6815
|
shared_nonce = @partner_merchant_gateway.payment_method_nonce.create(
|
6709
|
-
@credit_card.token
|
6816
|
+
@credit_card.token,
|
6710
6817
|
).payment_method_nonce.nonce
|
6711
6818
|
|
6712
6819
|
result = @granting_gateway.transaction.sale(
|
6713
6820
|
:shared_payment_method_nonce => shared_nonce,
|
6714
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6821
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6715
6822
|
)
|
6716
6823
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6717
6824
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6724,7 +6831,7 @@ describe Braintree::Transaction do
|
|
6724
6831
|
|
6725
6832
|
context "paypal here" do
|
6726
6833
|
it "gets the details of an auth/capture transaction" do
|
6727
|
-
result = Braintree::Transaction.find(
|
6834
|
+
result = Braintree::Transaction.find("paypal_here_auth_capture_id")
|
6728
6835
|
result.payment_instrument_type.should eq(Braintree::PaymentInstrumentType::PayPalHere)
|
6729
6836
|
result.paypal_here_details.should_not be_nil
|
6730
6837
|
|
@@ -6741,7 +6848,7 @@ describe Braintree::Transaction do
|
|
6741
6848
|
end
|
6742
6849
|
|
6743
6850
|
it "gets the details of a sale transaction" do
|
6744
|
-
result = Braintree::Transaction.find(
|
6851
|
+
result = Braintree::Transaction.find("paypal_here_sale_id")
|
6745
6852
|
result.paypal_here_details.should_not be_nil
|
6746
6853
|
|
6747
6854
|
details = result.paypal_here_details
|
@@ -6749,7 +6856,7 @@ describe Braintree::Transaction do
|
|
6749
6856
|
end
|
6750
6857
|
|
6751
6858
|
it "gets the details of a refunded sale transaction" do
|
6752
|
-
result = Braintree::Transaction.find(
|
6859
|
+
result = Braintree::Transaction.find("paypal_here_refund_id")
|
6753
6860
|
result.paypal_here_details.should_not be_nil
|
6754
6861
|
|
6755
6862
|
details = result.paypal_here_details
|
@@ -6774,7 +6881,7 @@ describe Braintree::Transaction do
|
|
6774
6881
|
customer = Braintree::Customer.create!
|
6775
6882
|
result = Braintree::PaymentMethod.create(
|
6776
6883
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
6777
|
-
:customer_id => customer.id
|
6884
|
+
:customer_id => customer.id,
|
6778
6885
|
)
|
6779
6886
|
payment_method_token = result.payment_method.token
|
6780
6887
|
|
@@ -6789,4 +6896,266 @@ describe Braintree::Transaction do
|
|
6789
6896
|
transaction.processed_with_network_token?.should == false
|
6790
6897
|
end
|
6791
6898
|
end
|
6899
|
+
|
6900
|
+
describe "installments" do
|
6901
|
+
it "creates a transaction with an installment count" do
|
6902
|
+
result = Braintree::Transaction.create(
|
6903
|
+
:type => "sale",
|
6904
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6905
|
+
:credit_card => {
|
6906
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6907
|
+
:expiration_date => "05/2009"
|
6908
|
+
},
|
6909
|
+
:amount => "100.01",
|
6910
|
+
:installments => {
|
6911
|
+
:count => 12,
|
6912
|
+
},
|
6913
|
+
)
|
6914
|
+
|
6915
|
+
expect(result.success?).to eq(true)
|
6916
|
+
expect(result.transaction.installment_count).to eq(12)
|
6917
|
+
end
|
6918
|
+
|
6919
|
+
it "creates a transaction with a installments during capture" do
|
6920
|
+
result = Braintree::Transaction.create(
|
6921
|
+
:type => "sale",
|
6922
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6923
|
+
:credit_card => {
|
6924
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6925
|
+
:expiration_date => "05/2009"
|
6926
|
+
},
|
6927
|
+
:amount => "100.01",
|
6928
|
+
:installments => {
|
6929
|
+
:count => 12,
|
6930
|
+
},
|
6931
|
+
:options => {
|
6932
|
+
:submit_for_settlement => true,
|
6933
|
+
},
|
6934
|
+
)
|
6935
|
+
|
6936
|
+
expect(result.success?).to eq(true)
|
6937
|
+
transaction = result.transaction
|
6938
|
+
expect(transaction.installment_count).to eq(12)
|
6939
|
+
|
6940
|
+
installments = transaction.installments
|
6941
|
+
expect(installments.map(&:id)).to match_array((1..12).map { |i| "#{transaction.id}_INST_#{i}" })
|
6942
|
+
expect(installments.map(&:amount)).to match_array([BigDecimal("8.33")] * 11 + [BigDecimal("8.38")])
|
6943
|
+
end
|
6944
|
+
|
6945
|
+
it "can refund a transaction with installments" do
|
6946
|
+
sale_result = Braintree::Transaction.create(
|
6947
|
+
:type => "sale",
|
6948
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
6949
|
+
:credit_card => {
|
6950
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6951
|
+
:expiration_date => "05/2009"
|
6952
|
+
},
|
6953
|
+
:amount => "100.01",
|
6954
|
+
:installments => {
|
6955
|
+
:count => 12,
|
6956
|
+
},
|
6957
|
+
:options => {
|
6958
|
+
:submit_for_settlement => true,
|
6959
|
+
},
|
6960
|
+
)
|
6961
|
+
|
6962
|
+
expect(sale_result.success?).to eq(true)
|
6963
|
+
sale_transaction = sale_result.transaction
|
6964
|
+
|
6965
|
+
refund_result = Braintree::Transaction.refund(sale_transaction.id, "49.99")
|
6966
|
+
|
6967
|
+
expect(refund_result.success?).to eq(true)
|
6968
|
+
refund_transaction = refund_result.transaction
|
6969
|
+
installments = refund_transaction.refunded_installments
|
6970
|
+
|
6971
|
+
(1..11).each do |i|
|
6972
|
+
installment = installments.find { |installment| installment.id == "#{sale_transaction.id}_INST_#{i}" }
|
6973
|
+
|
6974
|
+
expect(installment.amount).to eq(BigDecimal("8.33"))
|
6975
|
+
expect(installment.adjustments.map(&:amount)).to match_array([BigDecimal("-4.16")])
|
6976
|
+
expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
|
6977
|
+
end
|
6978
|
+
|
6979
|
+
installment = installments.find { |installment| installment.id == "#{sale_transaction.id}_INST_12" }
|
6980
|
+
|
6981
|
+
expect(installment.amount).to eq(BigDecimal("8.38"))
|
6982
|
+
expect(installment.adjustments.map(&:amount)).to match_array([BigDecimal("-4.23")])
|
6983
|
+
expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
|
6984
|
+
end
|
6985
|
+
end
|
6986
|
+
|
6987
|
+
describe "Manual Key Entry" do
|
6988
|
+
context "with correct encrypted payment reader card details" do
|
6989
|
+
it "returns a success response" do
|
6990
|
+
result = Braintree::Transaction.sale(
|
6991
|
+
:amount => "10.00",
|
6992
|
+
:credit_card => {
|
6993
|
+
:payment_reader_card_details => {
|
6994
|
+
:encrypted_card_data => "8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881",
|
6995
|
+
:key_serial_number => "FFFFFF02000572A00005",
|
6996
|
+
},
|
6997
|
+
},
|
6998
|
+
)
|
6999
|
+
|
7000
|
+
expect(result).to be_success
|
7001
|
+
end
|
7002
|
+
end
|
7003
|
+
|
7004
|
+
context "with invalid encrypted payment reader card details" do
|
7005
|
+
it "returns a failure response" do
|
7006
|
+
result = Braintree::Transaction.sale(
|
7007
|
+
:amount => "10.00",
|
7008
|
+
:credit_card => {
|
7009
|
+
:payment_reader_card_details => {
|
7010
|
+
:encrypted_card_data => "invalid",
|
7011
|
+
:key_serial_number => "invalid",
|
7012
|
+
},
|
7013
|
+
},
|
7014
|
+
)
|
7015
|
+
|
7016
|
+
expect(result).not_to be_success
|
7017
|
+
expect(result.errors.for(:transaction).first.code)
|
7018
|
+
.to eq(Braintree::ErrorCodes::Transaction::PaymentInstrumentNotSupportedByMerchantAccount)
|
7019
|
+
end
|
7020
|
+
end
|
7021
|
+
end
|
7022
|
+
|
7023
|
+
describe "Adjust Authorization" do
|
7024
|
+
let(:first_data_master_transaction_params) do
|
7025
|
+
{
|
7026
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
7027
|
+
:amount => "75.50",
|
7028
|
+
:credit_card => {
|
7029
|
+
:number => "5105105105105100",
|
7030
|
+
:expiration_date => "05/2012"
|
7031
|
+
}
|
7032
|
+
}
|
7033
|
+
end
|
7034
|
+
let(:first_data_visa_transaction_params) do
|
7035
|
+
{
|
7036
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
7037
|
+
:amount => "75.50",
|
7038
|
+
:credit_card => {
|
7039
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7040
|
+
:expiration_date => "06/2009"
|
7041
|
+
}
|
7042
|
+
}
|
7043
|
+
end
|
7044
|
+
context "successful authorization" do
|
7045
|
+
it "returns success response" do
|
7046
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7047
|
+
expect(initial_transaction.success?).to eq(true)
|
7048
|
+
|
7049
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7050
|
+
initial_transaction.transaction.id, "85.50"
|
7051
|
+
)
|
7052
|
+
|
7053
|
+
expect(adjustment_transaction.success?).to eq(true)
|
7054
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("85.50"))
|
7055
|
+
end
|
7056
|
+
end
|
7057
|
+
|
7058
|
+
context "unsuccessful authorization" do
|
7059
|
+
it "returns failure, when processor does not support multi auth adjustment" do
|
7060
|
+
initial_transaction = Braintree::Transaction.sale(
|
7061
|
+
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
7062
|
+
:amount => "75.50",
|
7063
|
+
:credit_card => {
|
7064
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7065
|
+
:expiration_date => "06/2009"
|
7066
|
+
},
|
7067
|
+
)
|
7068
|
+
expect(initial_transaction.success?).to eq(true)
|
7069
|
+
|
7070
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7071
|
+
initial_transaction.transaction.id, "85.50"
|
7072
|
+
)
|
7073
|
+
|
7074
|
+
|
7075
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7076
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7077
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportAuthAdjustment)
|
7078
|
+
end
|
7079
|
+
|
7080
|
+
it "returns failure response, when adjusted amount submitted is zero" do
|
7081
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7082
|
+
expect(initial_transaction.success?).to eq(true)
|
7083
|
+
|
7084
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7085
|
+
initial_transaction.transaction.id, "0.0"
|
7086
|
+
)
|
7087
|
+
|
7088
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7089
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7090
|
+
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AdjustmentAmountMustBeGreaterThanZero)
|
7091
|
+
end
|
7092
|
+
|
7093
|
+
it "returns failure response, when adjusted amount submitted same as authorized amount" do
|
7094
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7095
|
+
expect(initial_transaction.success?).to eq(true)
|
7096
|
+
|
7097
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7098
|
+
initial_transaction.transaction.id, "75.50"
|
7099
|
+
)
|
7100
|
+
|
7101
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7102
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7103
|
+
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
|
7104
|
+
end
|
7105
|
+
|
7106
|
+
it "returns failure, when transaction status is not authorized" do
|
7107
|
+
additional_params = {:options => {:submit_for_settlement => true}}
|
7108
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7109
|
+
expect(initial_transaction.success?).to eq(true)
|
7110
|
+
|
7111
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7112
|
+
initial_transaction.transaction.id, "85.50"
|
7113
|
+
)
|
7114
|
+
|
7115
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7116
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7117
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
|
7118
|
+
end
|
7119
|
+
|
7120
|
+
it "returns failure, when transaction authorization type final or undefined" do
|
7121
|
+
additional_params = {:transaction_source => "recurring_first"}
|
7122
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7123
|
+
expect(initial_transaction.success?).to eq(true)
|
7124
|
+
|
7125
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7126
|
+
initial_transaction.transaction.id, "85.50"
|
7127
|
+
)
|
7128
|
+
|
7129
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7130
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7131
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionIsNotEligibleForAdjustment)
|
7132
|
+
end
|
7133
|
+
|
7134
|
+
it "returns failure, when processor does not support incremental auth" do
|
7135
|
+
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7136
|
+
expect(initial_transaction.success?).to eq(true)
|
7137
|
+
|
7138
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7139
|
+
initial_transaction.transaction.id, "85.50"
|
7140
|
+
)
|
7141
|
+
|
7142
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7143
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7144
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportIncrementalAuth)
|
7145
|
+
end
|
7146
|
+
|
7147
|
+
it "returns failure, when processor does not support auth reversal" do
|
7148
|
+
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7149
|
+
expect(initial_transaction.success?).to eq(true)
|
7150
|
+
|
7151
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7152
|
+
initial_transaction.transaction.id, "65.50"
|
7153
|
+
)
|
7154
|
+
|
7155
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7156
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7157
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialAuthReversal)
|
7158
|
+
end
|
7159
|
+
end
|
7160
|
+
end
|
6792
7161
|
end
|