braintree 3.0.1 → 4.0.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 +2 -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/bin_data.rb +9 -2
- 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 +4 -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 +10 -2
- 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 +4 -6
- 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 +43 -26
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction_gateway.rb +26 -5
- 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 +2 -2
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -19
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -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 +124 -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 +343 -149
- data/spec/integration/braintree/dispute_search_spec.rb +29 -4
- 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 +326 -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 +736 -380
- 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 +9 -9
- 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 +14 -4
- 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 +3 -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 +72 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +15 -19
- 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,}$/
|
@@ -445,6 +482,7 @@ describe Braintree::Transaction do
|
|
445
482
|
result.transaction.credit_card_details.expiration_date.should == "05/2009"
|
446
483
|
result.transaction.credit_card_details.customer_location.should == "US"
|
447
484
|
result.transaction.retrieval_reference_number.should_not be_nil
|
485
|
+
result.transaction.acquirer_reference_number.should be_nil
|
448
486
|
end
|
449
487
|
|
450
488
|
it "returns a successful network response code if successful" do
|
@@ -454,7 +492,7 @@ describe Braintree::Transaction do
|
|
454
492
|
:credit_card => {
|
455
493
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
456
494
|
:expiration_date => "05/2009"
|
457
|
-
}
|
495
|
+
},
|
458
496
|
)
|
459
497
|
expect(result.success?).to eq(true)
|
460
498
|
expect(result.transaction.type).to eq("sale")
|
@@ -476,7 +514,7 @@ describe Braintree::Transaction do
|
|
476
514
|
oauth_gateway = Braintree::Gateway.new(
|
477
515
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
478
516
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
479
|
-
:logger => Logger.new("/dev/null")
|
517
|
+
:logger => Logger.new("/dev/null"),
|
480
518
|
)
|
481
519
|
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
482
520
|
:merchant_public_id => "integration_merchant_id",
|
@@ -485,7 +523,7 @@ describe Braintree::Transaction do
|
|
485
523
|
|
486
524
|
gateway = Braintree::Gateway.new(
|
487
525
|
:access_token => access_token,
|
488
|
-
:logger => Logger.new("/dev/null")
|
526
|
+
:logger => Logger.new("/dev/null"),
|
489
527
|
)
|
490
528
|
|
491
529
|
result = gateway.transaction.create(
|
@@ -494,7 +532,7 @@ describe Braintree::Transaction do
|
|
494
532
|
:credit_card => {
|
495
533
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
496
534
|
:expiration_date => "05/2009"
|
497
|
-
}
|
535
|
+
},
|
498
536
|
)
|
499
537
|
|
500
538
|
result.success?.should == true
|
@@ -537,7 +575,7 @@ describe Braintree::Transaction do
|
|
537
575
|
:customer_ip => "192.168.0.1",
|
538
576
|
:customer_location_zip => "91244",
|
539
577
|
:customer_tenure => "20",
|
540
|
-
}
|
578
|
+
},
|
541
579
|
)
|
542
580
|
|
543
581
|
result.success?.should == true
|
@@ -547,7 +585,7 @@ describe Braintree::Transaction do
|
|
547
585
|
result = Braintree::Customer.create()
|
548
586
|
address_result = Braintree::Address.create(
|
549
587
|
:customer_id => result.customer.id,
|
550
|
-
:country_code_alpha2 => "US"
|
588
|
+
:country_code_alpha2 => "US",
|
551
589
|
)
|
552
590
|
|
553
591
|
result = Braintree::Transaction.create(
|
@@ -558,7 +596,7 @@ describe Braintree::Transaction do
|
|
558
596
|
:credit_card => {
|
559
597
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
560
598
|
:expiration_date => "05/2009"
|
561
|
-
}
|
599
|
+
},
|
562
600
|
)
|
563
601
|
|
564
602
|
result.success?.should == true
|
@@ -571,7 +609,7 @@ describe Braintree::Transaction do
|
|
571
609
|
:credit_card => {
|
572
610
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
573
611
|
:expiration_date => "05/2009"
|
574
|
-
}
|
612
|
+
},
|
575
613
|
)
|
576
614
|
result.success?.should == false
|
577
615
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -590,7 +628,7 @@ describe Braintree::Transaction do
|
|
590
628
|
:credit_card => {
|
591
629
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
592
630
|
:expiration_date => "05/2009"
|
593
|
-
}
|
631
|
+
},
|
594
632
|
)
|
595
633
|
result.success?.should == false
|
596
634
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -627,7 +665,7 @@ describe Braintree::Transaction do
|
|
627
665
|
:options => {
|
628
666
|
:add_billing_address_to_payment_method => true,
|
629
667
|
:store_in_vault => true
|
630
|
-
}
|
668
|
+
},
|
631
669
|
)
|
632
670
|
result.success?.should == true
|
633
671
|
transaction = result.transaction
|
@@ -657,7 +695,7 @@ describe Braintree::Transaction do
|
|
657
695
|
:billing => {
|
658
696
|
:country_name => "Botswana",
|
659
697
|
:country_code_alpha2 => "US",
|
660
|
-
}
|
698
|
+
},
|
661
699
|
)
|
662
700
|
|
663
701
|
result.success?.should == false
|
@@ -673,7 +711,7 @@ describe Braintree::Transaction do
|
|
673
711
|
},
|
674
712
|
:billing => {
|
675
713
|
:country_code_alpha2 => "ZZ"
|
676
|
-
}
|
714
|
+
},
|
677
715
|
)
|
678
716
|
|
679
717
|
result.success?.should == false
|
@@ -690,7 +728,7 @@ describe Braintree::Transaction do
|
|
690
728
|
},
|
691
729
|
:billing => {
|
692
730
|
:country_code_alpha3 => "ZZZ"
|
693
|
-
}
|
731
|
+
},
|
694
732
|
)
|
695
733
|
|
696
734
|
result.success?.should == false
|
@@ -707,7 +745,7 @@ describe Braintree::Transaction do
|
|
707
745
|
},
|
708
746
|
:billing => {
|
709
747
|
:country_code_numeric => "FOO"
|
710
|
-
}
|
748
|
+
},
|
711
749
|
)
|
712
750
|
|
713
751
|
result.success?.should == false
|
@@ -738,7 +776,7 @@ describe Braintree::Transaction do
|
|
738
776
|
},
|
739
777
|
:shipping => {
|
740
778
|
:phone_number => "123-234-3456=098765"
|
741
|
-
}
|
779
|
+
},
|
742
780
|
)
|
743
781
|
|
744
782
|
result.success?.should == false
|
@@ -754,7 +792,7 @@ describe Braintree::Transaction do
|
|
754
792
|
},
|
755
793
|
:shipping => {
|
756
794
|
:shipping_method => "urgent"
|
757
|
-
}
|
795
|
+
},
|
758
796
|
)
|
759
797
|
|
760
798
|
result.success?.should == false
|
@@ -770,7 +808,7 @@ describe Braintree::Transaction do
|
|
770
808
|
},
|
771
809
|
:billing => {
|
772
810
|
:phone_number => "123-234-3456=098765"
|
773
|
-
}
|
811
|
+
},
|
774
812
|
)
|
775
813
|
|
776
814
|
result.success?.should == false
|
@@ -794,7 +832,7 @@ describe Braintree::Transaction do
|
|
794
832
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
795
833
|
:expiration_date => "05/2009",
|
796
834
|
:cvv => "200"
|
797
|
-
}
|
835
|
+
},
|
798
836
|
)
|
799
837
|
result.success?.should == false
|
800
838
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::CVV
|
@@ -809,17 +847,17 @@ describe Braintree::Transaction do
|
|
809
847
|
gateway = Braintree::Gateway.new(
|
810
848
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
811
849
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
812
|
-
:logger => Logger.new("/dev/null")
|
850
|
+
:logger => Logger.new("/dev/null"),
|
813
851
|
)
|
814
852
|
result = gateway.merchant.create(
|
815
853
|
:email => "name@email.com",
|
816
854
|
:country_code_alpha3 => "USA",
|
817
|
-
:payment_methods => ["credit_card", "paypal"]
|
855
|
+
:payment_methods => ["credit_card", "paypal"],
|
818
856
|
)
|
819
857
|
|
820
858
|
gateway = Braintree::Gateway.new(
|
821
859
|
:access_token => result.credentials.access_token,
|
822
|
-
:logger => Logger.new("/dev/null")
|
860
|
+
:logger => Logger.new("/dev/null"),
|
823
861
|
)
|
824
862
|
|
825
863
|
result = gateway.transaction.create(
|
@@ -828,7 +866,7 @@ describe Braintree::Transaction do
|
|
828
866
|
:credit_card => {
|
829
867
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
830
868
|
:expiration_date => "05/2020"
|
831
|
-
}
|
869
|
+
},
|
832
870
|
)
|
833
871
|
result.success?.should == false
|
834
872
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete
|
@@ -852,7 +890,7 @@ describe Braintree::Transaction do
|
|
852
890
|
:credit_card => {
|
853
891
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
854
892
|
:expiration_date => "05/2009"
|
855
|
-
}
|
893
|
+
},
|
856
894
|
)
|
857
895
|
result.success?.should == false
|
858
896
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVS
|
@@ -882,7 +920,7 @@ describe Braintree::Transaction do
|
|
882
920
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
883
921
|
:expiration_date => "05/2009",
|
884
922
|
:cvv => "200"
|
885
|
-
}
|
923
|
+
},
|
886
924
|
)
|
887
925
|
result.success?.should == false
|
888
926
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVSAndCVV
|
@@ -894,14 +932,14 @@ describe Braintree::Transaction do
|
|
894
932
|
end
|
895
933
|
|
896
934
|
it "exposes the fraud gateway rejection reason" do
|
897
|
-
|
935
|
+
with_advanced_fraud_kount_integration_merchant do
|
898
936
|
result = Braintree::Transaction.sale(
|
899
937
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
900
938
|
:credit_card => {
|
901
939
|
:number => Braintree::Test::CreditCardNumbers::Fraud,
|
902
940
|
:expiration_date => "05/2017",
|
903
941
|
:cvv => "333"
|
904
|
-
}
|
942
|
+
},
|
905
943
|
)
|
906
944
|
result.success?.should == false
|
907
945
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::Fraud
|
@@ -909,14 +947,14 @@ describe Braintree::Transaction do
|
|
909
947
|
end
|
910
948
|
|
911
949
|
it "exposes the risk_threshold gateway rejection reason (via test cc num)" do
|
912
|
-
|
950
|
+
with_advanced_fraud_kount_integration_merchant do
|
913
951
|
result = Braintree::Transaction.sale(
|
914
952
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
915
953
|
:credit_card => {
|
916
954
|
:number => Braintree::Test::CreditCardNumbers::RiskThreshold,
|
917
955
|
:expiration_date => "05/2017",
|
918
956
|
:cvv => "333"
|
919
|
-
}
|
957
|
+
},
|
920
958
|
)
|
921
959
|
result.success?.should == false
|
922
960
|
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
|
@@ -924,7 +962,7 @@ describe Braintree::Transaction do
|
|
924
962
|
end
|
925
963
|
|
926
964
|
it "exposes the risk_threshold gateway rejection reason (via test test nonce)" do
|
927
|
-
|
965
|
+
with_advanced_fraud_kount_integration_merchant do
|
928
966
|
result = Braintree::Transaction.sale(
|
929
967
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
930
968
|
:payment_method_nonce => Braintree::Test::Nonce::GatewayRejectedRiskThresholds,
|
@@ -953,7 +991,7 @@ describe Braintree::Transaction do
|
|
953
991
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
954
992
|
:expiration_month => "05",
|
955
993
|
:expiration_year => "2011"
|
956
|
-
}
|
994
|
+
},
|
957
995
|
)
|
958
996
|
result.success?.should == true
|
959
997
|
result.transaction.credit_card_details.expiration_month.should == "05"
|
@@ -965,7 +1003,7 @@ describe Braintree::Transaction do
|
|
965
1003
|
result = Braintree::Transaction.create(
|
966
1004
|
:type => "sale",
|
967
1005
|
:amount => Braintree::Test::TransactionAmounts::Decline,
|
968
|
-
:customer_id => 123456789
|
1006
|
+
:customer_id => 123456789,
|
969
1007
|
)
|
970
1008
|
result.success?.should == false
|
971
1009
|
result.errors.for(:transaction).on(:customer_id)[0].code.should == "91510"
|
@@ -982,7 +1020,7 @@ describe Braintree::Transaction do
|
|
982
1020
|
},
|
983
1021
|
:custom_fields => {
|
984
1022
|
:store_me => "custom value"
|
985
|
-
}
|
1023
|
+
},
|
986
1024
|
)
|
987
1025
|
result.success?.should == true
|
988
1026
|
result.transaction.custom_fields.should == {:store_me => "custom value"}
|
@@ -997,7 +1035,7 @@ describe Braintree::Transaction do
|
|
997
1035
|
},
|
998
1036
|
:custom_fields => {
|
999
1037
|
:store_me => ""
|
1000
|
-
}
|
1038
|
+
},
|
1001
1039
|
)
|
1002
1040
|
|
1003
1041
|
result = Braintree::Transaction.find(create_result.transaction.id)
|
@@ -1015,7 +1053,7 @@ describe Braintree::Transaction do
|
|
1015
1053
|
},
|
1016
1054
|
:custom_fields => {
|
1017
1055
|
:invalid_key => "custom value"
|
1018
|
-
}
|
1056
|
+
},
|
1019
1057
|
)
|
1020
1058
|
result.success?.should == false
|
1021
1059
|
result.errors.for(:transaction).on(:custom_fields)[0].message.should == "Custom field is invalid: invalid_key."
|
@@ -1034,7 +1072,7 @@ describe Braintree::Transaction do
|
|
1034
1072
|
}
|
1035
1073
|
result = Braintree::Transaction.create(params[:transaction])
|
1036
1074
|
result.success?.should == false
|
1037
|
-
result.params.should == {:transaction => {:type =>
|
1075
|
+
result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
1038
1076
|
end
|
1039
1077
|
|
1040
1078
|
it "returns errors if validations fail (tests many errors at once for spec speed)" do
|
@@ -1054,7 +1092,7 @@ describe Braintree::Transaction do
|
|
1054
1092
|
}
|
1055
1093
|
result = Braintree::Transaction.create(params[:transaction])
|
1056
1094
|
result.success?.should == false
|
1057
|
-
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)
|
1058
1096
|
result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
|
1059
1097
|
result.errors.for(:transaction).on(:payment_method_token)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodTokenIsInvalid
|
1060
1098
|
result.errors.for(:transaction).on(:type)[0].code.should == Braintree::ErrorCodes::Transaction::TypeIsInvalid
|
@@ -1085,7 +1123,7 @@ describe Braintree::Transaction do
|
|
1085
1123
|
:credit_card => {
|
1086
1124
|
:account_type => "credit",
|
1087
1125
|
}
|
1088
|
-
}
|
1126
|
+
},
|
1089
1127
|
)
|
1090
1128
|
result.success?.should == false
|
1091
1129
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountNotSupportedByProcessor
|
@@ -1129,13 +1167,13 @@ describe Braintree::Transaction do
|
|
1129
1167
|
:credit_card => {
|
1130
1168
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1131
1169
|
:expiration_date => "05/2010"
|
1132
|
-
}
|
1170
|
+
},
|
1133
1171
|
)
|
1134
1172
|
result = Braintree::Transaction.create(
|
1135
1173
|
:type => "sale",
|
1136
1174
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1137
1175
|
:customer_id => customer.id,
|
1138
|
-
:payment_method_token => customer.credit_cards[0].token + "x"
|
1176
|
+
:payment_method_token => customer.credit_cards[0].token + "x",
|
1139
1177
|
)
|
1140
1178
|
result.success?.should == false
|
1141
1179
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer
|
@@ -1147,7 +1185,7 @@ describe Braintree::Transaction do
|
|
1147
1185
|
:credit_card => {
|
1148
1186
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1149
1187
|
:expiration_date => "05/2010"
|
1150
|
-
}
|
1188
|
+
},
|
1151
1189
|
)
|
1152
1190
|
result = Braintree::Transaction.create(
|
1153
1191
|
:type => "sale",
|
@@ -1156,7 +1194,7 @@ describe Braintree::Transaction do
|
|
1156
1194
|
:credit_card => {
|
1157
1195
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1158
1196
|
:expiration_date => "12/12"
|
1159
|
-
}
|
1197
|
+
},
|
1160
1198
|
)
|
1161
1199
|
result.success?.should == true
|
1162
1200
|
result.transaction.credit_card_details.masked_number.should == "401288******1881"
|
@@ -1168,7 +1206,7 @@ describe Braintree::Transaction do
|
|
1168
1206
|
:credit_card => {
|
1169
1207
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1170
1208
|
:expiration_date => "05/2010"
|
1171
|
-
}
|
1209
|
+
},
|
1172
1210
|
)
|
1173
1211
|
result = Braintree::Transaction.create(
|
1174
1212
|
:type => "sale",
|
@@ -1178,7 +1216,7 @@ describe Braintree::Transaction do
|
|
1178
1216
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1179
1217
|
:expiration_date => "12/12",
|
1180
1218
|
},
|
1181
|
-
:options => {
|
1219
|
+
:options => {:store_in_vault => true},
|
1182
1220
|
)
|
1183
1221
|
result.success?.should == true
|
1184
1222
|
result.transaction.credit_card_details.masked_number.should == "401288******1881"
|
@@ -1192,7 +1230,7 @@ describe Braintree::Transaction do
|
|
1192
1230
|
:credit_card => {
|
1193
1231
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1194
1232
|
:expiration_date => "05/2010"
|
1195
|
-
}
|
1233
|
+
},
|
1196
1234
|
)
|
1197
1235
|
|
1198
1236
|
result = Braintree::Subscription.create(
|
@@ -1223,7 +1261,7 @@ describe Braintree::Transaction do
|
|
1223
1261
|
:never_expires => true
|
1224
1262
|
}
|
1225
1263
|
]
|
1226
|
-
}
|
1264
|
+
},
|
1227
1265
|
)
|
1228
1266
|
|
1229
1267
|
result.success?.should be(true)
|
@@ -1264,15 +1302,15 @@ describe Braintree::Transaction do
|
|
1264
1302
|
:expiration_date => "05/2009"
|
1265
1303
|
},
|
1266
1304
|
:descriptor => {
|
1267
|
-
:name =>
|
1268
|
-
:phone =>
|
1305
|
+
:name => "123*123456789012345678",
|
1306
|
+
:phone => "3334445555",
|
1269
1307
|
:url => "ebay.com"
|
1270
|
-
}
|
1308
|
+
},
|
1271
1309
|
)
|
1272
1310
|
result.success?.should == true
|
1273
|
-
result.transaction.descriptor.name.should ==
|
1274
|
-
result.transaction.descriptor.phone.should ==
|
1275
|
-
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"
|
1276
1314
|
end
|
1277
1315
|
|
1278
1316
|
it "has validation errors if format is invalid" do
|
@@ -1283,10 +1321,10 @@ describe Braintree::Transaction do
|
|
1283
1321
|
:expiration_date => "05/2009"
|
1284
1322
|
},
|
1285
1323
|
:descriptor => {
|
1286
|
-
:name =>
|
1287
|
-
:phone =>
|
1288
|
-
:url =>
|
1289
|
-
}
|
1324
|
+
:name => "badcompanyname12*badproduct12",
|
1325
|
+
:phone => "%bad4445555",
|
1326
|
+
:url => "12345678901234"
|
1327
|
+
},
|
1290
1328
|
)
|
1291
1329
|
result.success?.should == false
|
1292
1330
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -1303,14 +1341,14 @@ describe Braintree::Transaction do
|
|
1303
1341
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1304
1342
|
:expiration_date => "05/2009"
|
1305
1343
|
},
|
1306
|
-
:tax_amount =>
|
1344
|
+
:tax_amount => "0.05",
|
1307
1345
|
:tax_exempt => false,
|
1308
|
-
:purchase_order_number =>
|
1346
|
+
:purchase_order_number => "12345678901234567",
|
1309
1347
|
)
|
1310
1348
|
result.success?.should == true
|
1311
1349
|
result.transaction.tax_amount.should == BigDecimal("0.05")
|
1312
1350
|
result.transaction.tax_exempt.should == false
|
1313
|
-
result.transaction.purchase_order_number.should ==
|
1351
|
+
result.transaction.purchase_order_number.should == "12345678901234567"
|
1314
1352
|
end
|
1315
1353
|
|
1316
1354
|
it "accepts tax_amount as a BigDecimal" do
|
@@ -1320,8 +1358,8 @@ describe Braintree::Transaction do
|
|
1320
1358
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1321
1359
|
:expiration_date => "05/2009"
|
1322
1360
|
},
|
1323
|
-
:tax_amount => BigDecimal(
|
1324
|
-
:tax_exempt => true
|
1361
|
+
:tax_amount => BigDecimal("1.99"),
|
1362
|
+
:tax_exempt => true,
|
1325
1363
|
)
|
1326
1364
|
result.success?.should == true
|
1327
1365
|
result.transaction.tax_amount.should == BigDecimal("1.99")
|
@@ -1337,7 +1375,7 @@ describe Braintree::Transaction do
|
|
1337
1375
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1338
1376
|
:expiration_date => "05/2009"
|
1339
1377
|
},
|
1340
|
-
:tax_amount =>
|
1378
|
+
:tax_amount => "abcd",
|
1341
1379
|
)
|
1342
1380
|
result.success?.should == false
|
1343
1381
|
result.errors.for(:transaction).on(:tax_amount)[0].code.should == Braintree::ErrorCodes::Transaction::TaxAmountFormatIsInvalid
|
@@ -1350,7 +1388,7 @@ describe Braintree::Transaction do
|
|
1350
1388
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1351
1389
|
:expiration_date => "05/2009"
|
1352
1390
|
},
|
1353
|
-
:purchase_order_number =>
|
1391
|
+
:purchase_order_number => "a" * 18,
|
1354
1392
|
)
|
1355
1393
|
result.success?.should == false
|
1356
1394
|
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsTooLong
|
@@ -1363,7 +1401,7 @@ describe Braintree::Transaction do
|
|
1363
1401
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1364
1402
|
:expiration_date => "05/2009"
|
1365
1403
|
},
|
1366
|
-
:purchase_order_number => "\303\237\303\245\342\210\202"
|
1404
|
+
:purchase_order_number => "\303\237\303\245\342\210\202",
|
1367
1405
|
)
|
1368
1406
|
result.success?.should == false
|
1369
1407
|
result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsInvalid
|
@@ -1380,7 +1418,7 @@ describe Braintree::Transaction do
|
|
1380
1418
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1381
1419
|
:expiration_date => "12/12",
|
1382
1420
|
},
|
1383
|
-
:transaction_source => "recurring_first"
|
1421
|
+
:transaction_source => "recurring_first",
|
1384
1422
|
)
|
1385
1423
|
result.success?.should == true
|
1386
1424
|
result.transaction.recurring.should == true
|
@@ -1394,7 +1432,7 @@ describe Braintree::Transaction do
|
|
1394
1432
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1395
1433
|
:expiration_date => "12/12",
|
1396
1434
|
},
|
1397
|
-
:transaction_source => "recurring"
|
1435
|
+
:transaction_source => "recurring",
|
1398
1436
|
)
|
1399
1437
|
result.success?.should == true
|
1400
1438
|
result.transaction.recurring.should == true
|
@@ -1408,7 +1446,7 @@ describe Braintree::Transaction do
|
|
1408
1446
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1409
1447
|
:expiration_date => "12/12",
|
1410
1448
|
},
|
1411
|
-
:transaction_source => "merchant"
|
1449
|
+
:transaction_source => "merchant",
|
1412
1450
|
)
|
1413
1451
|
result.success?.should == true
|
1414
1452
|
result.transaction.recurring.should == false
|
@@ -1422,7 +1460,7 @@ describe Braintree::Transaction do
|
|
1422
1460
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1423
1461
|
:expiration_date => "12/12",
|
1424
1462
|
},
|
1425
|
-
:transaction_source => "moto"
|
1463
|
+
:transaction_source => "moto",
|
1426
1464
|
)
|
1427
1465
|
result.success?.should == true
|
1428
1466
|
result.transaction.recurring.should == false
|
@@ -1436,7 +1474,7 @@ describe Braintree::Transaction do
|
|
1436
1474
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1437
1475
|
:expiration_date => "12/12",
|
1438
1476
|
},
|
1439
|
-
:transaction_source => "invalid_value"
|
1477
|
+
:transaction_source => "invalid_value",
|
1440
1478
|
)
|
1441
1479
|
result.success?.should == false
|
1442
1480
|
result.errors.for(:transaction).on(:transaction_source)[0].code.should == Braintree::ErrorCodes::Transaction::TransactionSourceIsInvalid
|
@@ -1456,7 +1494,7 @@ describe Braintree::Transaction do
|
|
1456
1494
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1457
1495
|
:expiration_date => "12/12",
|
1458
1496
|
},
|
1459
|
-
:options => {
|
1497
|
+
:options => {:store_in_vault_on_success => true},
|
1460
1498
|
)
|
1461
1499
|
result.success?.should == true
|
1462
1500
|
result.transaction.vault_customer.last_name.should == "Doe"
|
@@ -1475,7 +1513,7 @@ describe Braintree::Transaction do
|
|
1475
1513
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1476
1514
|
:expiration_date => "12/12",
|
1477
1515
|
},
|
1478
|
-
:options => {
|
1516
|
+
:options => {:store_in_vault_on_success => true},
|
1479
1517
|
)
|
1480
1518
|
result.success?.should == false
|
1481
1519
|
result.transaction.vault_customer.should be_nil
|
@@ -1495,7 +1533,7 @@ describe Braintree::Transaction do
|
|
1495
1533
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1496
1534
|
:expiration_date => "12/12",
|
1497
1535
|
},
|
1498
|
-
:options => {
|
1536
|
+
:options => {:store_in_vault_on_success => false},
|
1499
1537
|
)
|
1500
1538
|
result.success?.should == true
|
1501
1539
|
result.transaction.vault_customer.should be_nil
|
@@ -1513,7 +1551,7 @@ describe Braintree::Transaction do
|
|
1513
1551
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1514
1552
|
:expiration_date => "12/12",
|
1515
1553
|
},
|
1516
|
-
:options => {
|
1554
|
+
:options => {:store_in_vault_on_success => false},
|
1517
1555
|
)
|
1518
1556
|
result.success?.should == false
|
1519
1557
|
result.transaction.vault_customer.should be_nil
|
@@ -1532,7 +1570,7 @@ describe Braintree::Transaction do
|
|
1532
1570
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1533
1571
|
:expiration_date => "12/12",
|
1534
1572
|
},
|
1535
|
-
:service_fee_amount => "1.00"
|
1573
|
+
:service_fee_amount => "1.00",
|
1536
1574
|
)
|
1537
1575
|
result.success?.should == true
|
1538
1576
|
result.transaction.service_fee_amount.should == BigDecimal("1.00")
|
@@ -1547,7 +1585,7 @@ describe Braintree::Transaction do
|
|
1547
1585
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1548
1586
|
:expiration_date => "12/12",
|
1549
1587
|
},
|
1550
|
-
:service_fee_amount => "1.00"
|
1588
|
+
:service_fee_amount => "1.00",
|
1551
1589
|
)
|
1552
1590
|
result.success?.should == false
|
1553
1591
|
expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
|
@@ -1562,7 +1600,7 @@ describe Braintree::Transaction do
|
|
1562
1600
|
:credit_card => {
|
1563
1601
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1564
1602
|
:expiration_date => "12/12",
|
1565
|
-
}
|
1603
|
+
},
|
1566
1604
|
)
|
1567
1605
|
result.success?.should == false
|
1568
1606
|
expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
|
@@ -1572,7 +1610,7 @@ describe Braintree::Transaction do
|
|
1572
1610
|
it "raises an error if service fee amount is negative" do
|
1573
1611
|
result = Braintree::Transaction.create(
|
1574
1612
|
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
1575
|
-
:service_fee_amount => "-1.00"
|
1613
|
+
:service_fee_amount => "-1.00",
|
1576
1614
|
)
|
1577
1615
|
result.success?.should == false
|
1578
1616
|
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative
|
@@ -1581,7 +1619,7 @@ describe Braintree::Transaction do
|
|
1581
1619
|
it "raises an error if service fee amount is invalid" do
|
1582
1620
|
result = Braintree::Transaction.create(
|
1583
1621
|
:merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
|
1584
|
-
:service_fee_amount => "invalid amount"
|
1622
|
+
:service_fee_amount => "invalid amount",
|
1585
1623
|
)
|
1586
1624
|
result.success?.should == false
|
1587
1625
|
result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid
|
@@ -1599,7 +1637,7 @@ describe Braintree::Transaction do
|
|
1599
1637
|
:expiration_date => "12/12",
|
1600
1638
|
},
|
1601
1639
|
:service_fee_amount => "10.00",
|
1602
|
-
:options => {:hold_in_escrow => true}
|
1640
|
+
:options => {:hold_in_escrow => true},
|
1603
1641
|
)
|
1604
1642
|
|
1605
1643
|
result.success?.should == true
|
@@ -1616,7 +1654,7 @@ describe Braintree::Transaction do
|
|
1616
1654
|
:expiration_date => "12/12",
|
1617
1655
|
},
|
1618
1656
|
:service_fee_amount => "1.00",
|
1619
|
-
:options => {:hold_in_escrow => true}
|
1657
|
+
:options => {:hold_in_escrow => true},
|
1620
1658
|
)
|
1621
1659
|
result.success?.should == false
|
1622
1660
|
expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
|
@@ -1629,7 +1667,7 @@ describe Braintree::Transaction do
|
|
1629
1667
|
result = Braintree::Transaction.create(
|
1630
1668
|
:type => "sale",
|
1631
1669
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1632
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
1670
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
|
1633
1671
|
)
|
1634
1672
|
result.success?.should == true
|
1635
1673
|
result.transaction.credit_card_details.bin.should == "400934"
|
@@ -1646,7 +1684,7 @@ describe Braintree::Transaction do
|
|
1646
1684
|
},
|
1647
1685
|
:options => {
|
1648
1686
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
1649
|
-
}
|
1687
|
+
},
|
1650
1688
|
)
|
1651
1689
|
result.success?.should == true
|
1652
1690
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -1661,14 +1699,14 @@ describe Braintree::Transaction do
|
|
1661
1699
|
:expiration_month => "11",
|
1662
1700
|
:expiration_year => "2099",
|
1663
1701
|
},
|
1664
|
-
:share => true
|
1702
|
+
:share => true,
|
1665
1703
|
)
|
1666
1704
|
nonce.should_not be_nil
|
1667
1705
|
|
1668
1706
|
result = Braintree::Transaction.create(
|
1669
1707
|
:type => "sale",
|
1670
1708
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1671
|
-
:payment_method_nonce => nonce
|
1709
|
+
:payment_method_nonce => nonce,
|
1672
1710
|
)
|
1673
1711
|
result.success?.should == true
|
1674
1712
|
end
|
@@ -1683,14 +1721,14 @@ describe Braintree::Transaction do
|
|
1683
1721
|
},
|
1684
1722
|
:client_token_options => {
|
1685
1723
|
:customer_id => customer.id,
|
1686
|
-
}
|
1724
|
+
},
|
1687
1725
|
)
|
1688
1726
|
nonce.should_not be_nil
|
1689
1727
|
|
1690
1728
|
result = Braintree::Transaction.create(
|
1691
1729
|
:type => "sale",
|
1692
1730
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1693
|
-
:payment_method_nonce => nonce
|
1731
|
+
:payment_method_nonce => nonce,
|
1694
1732
|
)
|
1695
1733
|
result.success?.should == true
|
1696
1734
|
end
|
@@ -1703,14 +1741,14 @@ describe Braintree::Transaction do
|
|
1703
1741
|
},
|
1704
1742
|
:client_token_options => {
|
1705
1743
|
:customer_id => customer.id,
|
1706
|
-
}
|
1744
|
+
},
|
1707
1745
|
)
|
1708
1746
|
nonce.should_not be_nil
|
1709
1747
|
|
1710
1748
|
result = Braintree::Transaction.create(
|
1711
1749
|
:type => "sale",
|
1712
1750
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1713
|
-
:payment_method_nonce => nonce
|
1751
|
+
:payment_method_nonce => nonce,
|
1714
1752
|
)
|
1715
1753
|
result.success?.should == true
|
1716
1754
|
result.transaction.paypal_details.should_not be_nil
|
@@ -1722,14 +1760,14 @@ describe Braintree::Transaction do
|
|
1722
1760
|
nonce = nonce_for_new_payment_method(
|
1723
1761
|
:paypal_account => {
|
1724
1762
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1725
|
-
}
|
1763
|
+
},
|
1726
1764
|
)
|
1727
1765
|
nonce.should_not be_nil
|
1728
1766
|
|
1729
1767
|
result = Braintree::Transaction.create(
|
1730
1768
|
:type => "sale",
|
1731
1769
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1732
|
-
:payment_method_nonce => nonce
|
1770
|
+
:payment_method_nonce => nonce,
|
1733
1771
|
)
|
1734
1772
|
result.success?.should == true
|
1735
1773
|
result.transaction.paypal_details.should_not be_nil
|
@@ -1741,7 +1779,7 @@ describe Braintree::Transaction do
|
|
1741
1779
|
result = Braintree::Transaction.create(
|
1742
1780
|
:type => "sale",
|
1743
1781
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1744
|
-
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa
|
1782
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
1745
1783
|
)
|
1746
1784
|
result.success?.should == true
|
1747
1785
|
result.transaction.should_not be_nil
|
@@ -1771,7 +1809,7 @@ describe Braintree::Transaction do
|
|
1771
1809
|
:type => "sale",
|
1772
1810
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1773
1811
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
1774
|
-
:options => {
|
1812
|
+
:options => {:store_in_vault_on_success => true},
|
1775
1813
|
)
|
1776
1814
|
result.success?.should == true
|
1777
1815
|
result.transaction.should_not be_nil
|
@@ -1792,7 +1830,7 @@ describe Braintree::Transaction do
|
|
1792
1830
|
result = Braintree::Transaction.create(
|
1793
1831
|
:type => "sale",
|
1794
1832
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1795
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
1833
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1796
1834
|
)
|
1797
1835
|
result.success?.should == true
|
1798
1836
|
result.transaction.should_not be_nil
|
@@ -1825,7 +1863,7 @@ describe Braintree::Transaction do
|
|
1825
1863
|
:type => "sale",
|
1826
1864
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1827
1865
|
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1828
|
-
:options => {
|
1866
|
+
:options => {:store_in_vault_on_success => true},
|
1829
1867
|
)
|
1830
1868
|
result.success?.should == true
|
1831
1869
|
result.transaction.should_not be_nil
|
@@ -1849,7 +1887,7 @@ describe Braintree::Transaction do
|
|
1849
1887
|
result = Braintree::Transaction.create(
|
1850
1888
|
:type => "sale",
|
1851
1889
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1852
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1890
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1853
1891
|
)
|
1854
1892
|
result.success?.should == true
|
1855
1893
|
result.transaction.should_not be_nil
|
@@ -1872,7 +1910,7 @@ describe Braintree::Transaction do
|
|
1872
1910
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
1873
1911
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1874
1912
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1875
|
-
:options => {:store_in_vault => true}
|
1913
|
+
:options => {:store_in_vault => true},
|
1876
1914
|
)
|
1877
1915
|
result.should be_success
|
1878
1916
|
|
@@ -1892,7 +1930,7 @@ describe Braintree::Transaction do
|
|
1892
1930
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
1893
1931
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1894
1932
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1895
|
-
: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"}},
|
1896
1934
|
)
|
1897
1935
|
result.should be_success
|
1898
1936
|
end
|
@@ -1902,7 +1940,7 @@ describe Braintree::Transaction do
|
|
1902
1940
|
result = Braintree::Transaction.create(
|
1903
1941
|
:type => "sale",
|
1904
1942
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1905
|
-
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable
|
1943
|
+
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
1906
1944
|
)
|
1907
1945
|
result.success?.should == true
|
1908
1946
|
result.transaction.should_not be_nil
|
@@ -1917,7 +1955,7 @@ describe Braintree::Transaction do
|
|
1917
1955
|
:paypal_account => {
|
1918
1956
|
:payer_id => "PAYER-1234",
|
1919
1957
|
:payment_id => "PAY-5678",
|
1920
|
-
}
|
1958
|
+
},
|
1921
1959
|
)
|
1922
1960
|
|
1923
1961
|
result.success?.should == true
|
@@ -1931,7 +1969,7 @@ describe Braintree::Transaction do
|
|
1931
1969
|
nonce = nonce_for_new_payment_method(
|
1932
1970
|
:paypal_account => {
|
1933
1971
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1934
|
-
}
|
1972
|
+
},
|
1935
1973
|
)
|
1936
1974
|
nonce.should_not be_nil
|
1937
1975
|
|
@@ -1941,7 +1979,7 @@ describe Braintree::Transaction do
|
|
1941
1979
|
:payment_method_nonce => nonce,
|
1942
1980
|
:paypal_account => {
|
1943
1981
|
:payee_id => "fake-payee-id"
|
1944
|
-
}
|
1982
|
+
},
|
1945
1983
|
)
|
1946
1984
|
|
1947
1985
|
result.success?.should == true
|
@@ -1955,7 +1993,7 @@ describe Braintree::Transaction do
|
|
1955
1993
|
nonce = nonce_for_new_payment_method(
|
1956
1994
|
:paypal_account => {
|
1957
1995
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1958
|
-
}
|
1996
|
+
},
|
1959
1997
|
)
|
1960
1998
|
nonce.should_not be_nil
|
1961
1999
|
|
@@ -1966,7 +2004,7 @@ describe Braintree::Transaction do
|
|
1966
2004
|
:paypal_account => {},
|
1967
2005
|
:options => {
|
1968
2006
|
:payee_id => "fake-payee-id"
|
1969
|
-
}
|
2007
|
+
},
|
1970
2008
|
)
|
1971
2009
|
|
1972
2010
|
result.success?.should == true
|
@@ -1980,7 +2018,7 @@ describe Braintree::Transaction do
|
|
1980
2018
|
nonce = nonce_for_new_payment_method(
|
1981
2019
|
:paypal_account => {
|
1982
2020
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1983
|
-
}
|
2021
|
+
},
|
1984
2022
|
)
|
1985
2023
|
nonce.should_not be_nil
|
1986
2024
|
|
@@ -1992,7 +2030,7 @@ describe Braintree::Transaction do
|
|
1992
2030
|
:paypal => {
|
1993
2031
|
:payee_id => "fake-payee-id"
|
1994
2032
|
}
|
1995
|
-
}
|
2033
|
+
},
|
1996
2034
|
)
|
1997
2035
|
|
1998
2036
|
result.success?.should == true
|
@@ -2006,7 +2044,7 @@ describe Braintree::Transaction do
|
|
2006
2044
|
nonce = nonce_for_new_payment_method(
|
2007
2045
|
:paypal_account => {
|
2008
2046
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2009
|
-
}
|
2047
|
+
},
|
2010
2048
|
)
|
2011
2049
|
nonce.should_not be_nil
|
2012
2050
|
|
@@ -2016,7 +2054,7 @@ describe Braintree::Transaction do
|
|
2016
2054
|
:payment_method_nonce => nonce,
|
2017
2055
|
:paypal_account => {
|
2018
2056
|
:payee_email => "bt_seller_us@paypal.com"
|
2019
|
-
}
|
2057
|
+
},
|
2020
2058
|
)
|
2021
2059
|
|
2022
2060
|
result.success?.should == true
|
@@ -2030,7 +2068,7 @@ describe Braintree::Transaction do
|
|
2030
2068
|
nonce = nonce_for_new_payment_method(
|
2031
2069
|
:paypal_account => {
|
2032
2070
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2033
|
-
}
|
2071
|
+
},
|
2034
2072
|
)
|
2035
2073
|
nonce.should_not be_nil
|
2036
2074
|
|
@@ -2041,7 +2079,7 @@ describe Braintree::Transaction do
|
|
2041
2079
|
:paypal_account => {},
|
2042
2080
|
:options => {
|
2043
2081
|
:payee_email => "bt_seller_us@paypal.com"
|
2044
|
-
}
|
2082
|
+
},
|
2045
2083
|
)
|
2046
2084
|
|
2047
2085
|
result.success?.should == true
|
@@ -2055,7 +2093,7 @@ describe Braintree::Transaction do
|
|
2055
2093
|
nonce = nonce_for_new_payment_method(
|
2056
2094
|
:paypal_account => {
|
2057
2095
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2058
|
-
}
|
2096
|
+
},
|
2059
2097
|
)
|
2060
2098
|
nonce.should_not be_nil
|
2061
2099
|
|
@@ -2067,7 +2105,7 @@ describe Braintree::Transaction do
|
|
2067
2105
|
:paypal => {
|
2068
2106
|
:payee_email => "bt_seller_us@paypal.com"
|
2069
2107
|
}
|
2070
|
-
}
|
2108
|
+
},
|
2071
2109
|
)
|
2072
2110
|
|
2073
2111
|
result.success?.should == true
|
@@ -2081,7 +2119,7 @@ describe Braintree::Transaction do
|
|
2081
2119
|
nonce = nonce_for_new_payment_method(
|
2082
2120
|
:paypal_account => {
|
2083
2121
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2084
|
-
}
|
2122
|
+
},
|
2085
2123
|
)
|
2086
2124
|
nonce.should_not be_nil
|
2087
2125
|
|
@@ -2093,7 +2131,7 @@ describe Braintree::Transaction do
|
|
2093
2131
|
:paypal => {
|
2094
2132
|
:custom_field => "Additional info"
|
2095
2133
|
}
|
2096
|
-
}
|
2134
|
+
},
|
2097
2135
|
)
|
2098
2136
|
|
2099
2137
|
result.success?.should == true
|
@@ -2107,7 +2145,7 @@ describe Braintree::Transaction do
|
|
2107
2145
|
nonce = nonce_for_new_payment_method(
|
2108
2146
|
:paypal_account => {
|
2109
2147
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2110
|
-
}
|
2148
|
+
},
|
2111
2149
|
)
|
2112
2150
|
nonce.should_not be_nil
|
2113
2151
|
|
@@ -2119,7 +2157,7 @@ describe Braintree::Transaction do
|
|
2119
2157
|
:paypal => {
|
2120
2158
|
:description => "A great product"
|
2121
2159
|
}
|
2122
|
-
}
|
2160
|
+
},
|
2123
2161
|
)
|
2124
2162
|
|
2125
2163
|
result.success?.should == true
|
@@ -2133,7 +2171,7 @@ describe Braintree::Transaction do
|
|
2133
2171
|
nonce = nonce_for_new_payment_method(
|
2134
2172
|
:paypal_account => {
|
2135
2173
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2136
|
-
}
|
2174
|
+
},
|
2137
2175
|
)
|
2138
2176
|
nonce.should_not be_nil
|
2139
2177
|
|
@@ -2148,7 +2186,7 @@ describe Braintree::Transaction do
|
|
2148
2186
|
:key2 => "value2",
|
2149
2187
|
}
|
2150
2188
|
}
|
2151
|
-
}
|
2189
|
+
},
|
2152
2190
|
)
|
2153
2191
|
|
2154
2192
|
# note - supplementary data is not returned in response
|
@@ -2162,7 +2200,7 @@ describe Braintree::Transaction do
|
|
2162
2200
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2163
2201
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2164
2202
|
:expiration_month => "12",
|
2165
|
-
:expiration_year => "2012"
|
2203
|
+
:expiration_year => "2012",
|
2166
2204
|
)
|
2167
2205
|
|
2168
2206
|
result = Braintree::Transaction.create(
|
@@ -2173,7 +2211,7 @@ describe Braintree::Transaction do
|
|
2173
2211
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2174
2212
|
:expiration_date => "12/12",
|
2175
2213
|
},
|
2176
|
-
:three_d_secure_token => three_d_secure_token
|
2214
|
+
:three_d_secure_token => three_d_secure_token,
|
2177
2215
|
)
|
2178
2216
|
|
2179
2217
|
result.success?.should == true
|
@@ -2185,7 +2223,7 @@ describe Braintree::Transaction do
|
|
2185
2223
|
:number => "4111111111111111",
|
2186
2224
|
:expiration_month => "11",
|
2187
2225
|
:expiration_year => "2099",
|
2188
|
-
}
|
2226
|
+
},
|
2189
2227
|
)
|
2190
2228
|
nonce.should_not be_nil
|
2191
2229
|
result = Braintree::Transaction.create(
|
@@ -2197,7 +2235,7 @@ describe Braintree::Transaction do
|
|
2197
2235
|
:three_d_secure => {
|
2198
2236
|
:required => true,
|
2199
2237
|
}
|
2200
|
-
}
|
2238
|
+
},
|
2201
2239
|
)
|
2202
2240
|
|
2203
2241
|
result.success?.should == false
|
@@ -2213,7 +2251,7 @@ describe Braintree::Transaction do
|
|
2213
2251
|
:credit_card => {
|
2214
2252
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2215
2253
|
:expiration_date => "12/12",
|
2216
|
-
}
|
2254
|
+
},
|
2217
2255
|
)
|
2218
2256
|
result.success?.should == true
|
2219
2257
|
end
|
@@ -2224,7 +2262,7 @@ describe Braintree::Transaction do
|
|
2224
2262
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2225
2263
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2226
2264
|
:expiration_month => "12",
|
2227
|
-
:expiration_year => "2022"
|
2265
|
+
:expiration_year => "2022",
|
2228
2266
|
)
|
2229
2267
|
|
2230
2268
|
result = Braintree::Transaction.create(
|
@@ -2235,7 +2273,7 @@ describe Braintree::Transaction do
|
|
2235
2273
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2236
2274
|
:expiration_date => "12/22",
|
2237
2275
|
},
|
2238
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2276
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2239
2277
|
)
|
2240
2278
|
|
2241
2279
|
result.success?.should == true
|
@@ -2249,7 +2287,7 @@ describe Braintree::Transaction do
|
|
2249
2287
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2250
2288
|
:expiration_date => "12/12",
|
2251
2289
|
},
|
2252
|
-
:three_d_secure_authentication_id => nil
|
2290
|
+
:three_d_secure_authentication_id => nil,
|
2253
2291
|
)
|
2254
2292
|
result.success?.should == false
|
2255
2293
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdIsInvalid
|
@@ -2259,7 +2297,7 @@ describe Braintree::Transaction do
|
|
2259
2297
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2260
2298
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2261
2299
|
:expiration_month => "12",
|
2262
|
-
:expiration_year => "2012"
|
2300
|
+
:expiration_year => "2012",
|
2263
2301
|
)
|
2264
2302
|
|
2265
2303
|
result = Braintree::Transaction.create(
|
@@ -2269,7 +2307,7 @@ describe Braintree::Transaction do
|
|
2269
2307
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2270
2308
|
:expiration_date => "12/12",
|
2271
2309
|
},
|
2272
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2310
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2273
2311
|
)
|
2274
2312
|
result.success?.should == false
|
2275
2313
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
|
@@ -2279,7 +2317,7 @@ describe Braintree::Transaction do
|
|
2279
2317
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2280
2318
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2281
2319
|
:expiration_month => "12",
|
2282
|
-
:expiration_year => "2012"
|
2320
|
+
:expiration_year => "2012",
|
2283
2321
|
)
|
2284
2322
|
|
2285
2323
|
result = Braintree::Transaction.create(
|
@@ -2290,7 +2328,7 @@ describe Braintree::Transaction do
|
|
2290
2328
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2291
2329
|
:expiration_date => "12/12",
|
2292
2330
|
},
|
2293
|
-
:three_d_secure_authentication_id => three_d_secure_authentication_id
|
2331
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2294
2332
|
)
|
2295
2333
|
result.success?.should == false
|
2296
2334
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
|
@@ -2300,7 +2338,7 @@ describe Braintree::Transaction do
|
|
2300
2338
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2301
2339
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2302
2340
|
:expiration_month => "12",
|
2303
|
-
:expiration_year => "2012"
|
2341
|
+
:expiration_year => "2012",
|
2304
2342
|
)
|
2305
2343
|
result = Braintree::Transaction.create(
|
2306
2344
|
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
|
@@ -2320,7 +2358,7 @@ describe Braintree::Transaction do
|
|
2320
2358
|
:directory_response => "Y",
|
2321
2359
|
:cavv_algorithm => "2",
|
2322
2360
|
:ds_transaction_id => "some_ds_id",
|
2323
|
-
}
|
2361
|
+
},
|
2324
2362
|
)
|
2325
2363
|
result.success?.should == false
|
2326
2364
|
result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdWithThreeDSecurePassThruIsInvalid
|
@@ -2333,7 +2371,7 @@ describe Braintree::Transaction do
|
|
2333
2371
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2334
2372
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2335
2373
|
:expiration_month => "12",
|
2336
|
-
:expiration_year => "2012"
|
2374
|
+
:expiration_year => "2012",
|
2337
2375
|
)
|
2338
2376
|
|
2339
2377
|
result = Braintree::Transaction.create(
|
@@ -2344,7 +2382,7 @@ describe Braintree::Transaction do
|
|
2344
2382
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2345
2383
|
:expiration_date => "12/12",
|
2346
2384
|
},
|
2347
|
-
:three_d_secure_token => three_d_secure_token
|
2385
|
+
:three_d_secure_token => three_d_secure_token,
|
2348
2386
|
)
|
2349
2387
|
|
2350
2388
|
result.success?.should == true
|
@@ -2359,7 +2397,7 @@ describe Braintree::Transaction do
|
|
2359
2397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2360
2398
|
:expiration_date => "12/12",
|
2361
2399
|
},
|
2362
|
-
:three_d_secure_token => nil
|
2400
|
+
:three_d_secure_token => nil,
|
2363
2401
|
)
|
2364
2402
|
result.success?.should == false
|
2365
2403
|
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTokenIsInvalid
|
@@ -2370,7 +2408,7 @@ describe Braintree::Transaction do
|
|
2370
2408
|
SpecHelper::ThreeDSecureMerchantAccountId,
|
2371
2409
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
2372
2410
|
:expiration_month => "12",
|
2373
|
-
:expiration_year => "2012"
|
2411
|
+
:expiration_year => "2012",
|
2374
2412
|
)
|
2375
2413
|
|
2376
2414
|
result = Braintree::Transaction.create(
|
@@ -2381,7 +2419,7 @@ describe Braintree::Transaction do
|
|
2381
2419
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
2382
2420
|
:expiration_date => "12/12",
|
2383
2421
|
},
|
2384
|
-
:three_d_secure_token => three_d_secure_token
|
2422
|
+
:three_d_secure_token => three_d_secure_token,
|
2385
2423
|
)
|
2386
2424
|
result.success?.should == false
|
2387
2425
|
result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionDataDoesntMatchVerify
|
@@ -2405,7 +2443,7 @@ describe Braintree::Transaction do
|
|
2405
2443
|
:directory_response => "Y",
|
2406
2444
|
:cavv_algorithm => "2",
|
2407
2445
|
:ds_transaction_id => "some_ds_id",
|
2408
|
-
}
|
2446
|
+
},
|
2409
2447
|
)
|
2410
2448
|
|
2411
2449
|
result.success?.should == true
|
@@ -2430,7 +2468,7 @@ describe Braintree::Transaction do
|
|
2430
2468
|
:directory_response => "Y",
|
2431
2469
|
:cavv_algorithm => "2",
|
2432
2470
|
:ds_transaction_id => "some_ds_id",
|
2433
|
-
}
|
2471
|
+
},
|
2434
2472
|
)
|
2435
2473
|
result.success?.should == false
|
2436
2474
|
result.errors.for(:transaction).on(:merchant_account_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureMerchantAccountDoesNotSupportCardType
|
@@ -2448,7 +2486,7 @@ describe Braintree::Transaction do
|
|
2448
2486
|
:eci_flag => "",
|
2449
2487
|
:cavv => "some_cavv",
|
2450
2488
|
:xid => "some_xid",
|
2451
|
-
}
|
2489
|
+
},
|
2452
2490
|
)
|
2453
2491
|
result.success?.should == false
|
2454
2492
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsRequired
|
@@ -2471,7 +2509,7 @@ describe Braintree::Transaction do
|
|
2471
2509
|
:directory_response => "Y",
|
2472
2510
|
:cavv_algorithm => "2",
|
2473
2511
|
:ds_transaction_id => "some_ds_id",
|
2474
|
-
}
|
2512
|
+
},
|
2475
2513
|
)
|
2476
2514
|
result.success?.should == false
|
2477
2515
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvIsRequired
|
@@ -2494,7 +2532,7 @@ describe Braintree::Transaction do
|
|
2494
2532
|
:directory_response => "Y",
|
2495
2533
|
:cavv_algorithm => "2",
|
2496
2534
|
:ds_transaction_id => "some_ds_id",
|
2497
|
-
}
|
2535
|
+
},
|
2498
2536
|
)
|
2499
2537
|
result.success?.should == false
|
2500
2538
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsInvalid
|
@@ -2517,7 +2555,7 @@ describe Braintree::Transaction do
|
|
2517
2555
|
:directory_response => "Y",
|
2518
2556
|
:cavv_algorithm => "2",
|
2519
2557
|
:ds_transaction_id => "some_ds_id",
|
2520
|
-
}
|
2558
|
+
},
|
2521
2559
|
)
|
2522
2560
|
result.success?.should == false
|
2523
2561
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid
|
@@ -2541,7 +2579,7 @@ describe Braintree::Transaction do
|
|
2541
2579
|
:directory_response => "Y",
|
2542
2580
|
:cavv_algorithm => "2",
|
2543
2581
|
:ds_transaction_id => "some_ds_id",
|
2544
|
-
}
|
2582
|
+
},
|
2545
2583
|
)
|
2546
2584
|
result.success?.should == false
|
2547
2585
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid
|
@@ -2565,7 +2603,7 @@ describe Braintree::Transaction do
|
|
2565
2603
|
:directory_response => "abc",
|
2566
2604
|
:cavv_algorithm => "2",
|
2567
2605
|
:ds_transaction_id => "some_ds_id",
|
2568
|
-
}
|
2606
|
+
},
|
2569
2607
|
)
|
2570
2608
|
result.success?.should == false
|
2571
2609
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:directory_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureDirectoryResponseIsInvalid
|
@@ -2589,7 +2627,7 @@ describe Braintree::Transaction do
|
|
2589
2627
|
:directory_response => "Y",
|
2590
2628
|
:cavv_algorithm => "bad_alg",
|
2591
2629
|
:ds_transaction_id => "some_ds_id",
|
2592
|
-
}
|
2630
|
+
},
|
2593
2631
|
)
|
2594
2632
|
result.success?.should == false
|
2595
2633
|
result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv_algorithm)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvAlgorithmIsInvalid
|
@@ -2601,12 +2639,12 @@ describe Braintree::Transaction do
|
|
2601
2639
|
it "can create a transaction" do
|
2602
2640
|
payment_method_result = Braintree::PaymentMethod.create(
|
2603
2641
|
:customer_id => Braintree::Customer.create.customer.id,
|
2604
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
2642
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
2605
2643
|
)
|
2606
2644
|
result = Braintree::Transaction.create(
|
2607
2645
|
:type => "sale",
|
2608
2646
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2609
|
-
:payment_method_token => payment_method_result.payment_method.token
|
2647
|
+
:payment_method_token => payment_method_result.payment_method.token,
|
2610
2648
|
)
|
2611
2649
|
|
2612
2650
|
result.should be_success
|
@@ -2621,13 +2659,13 @@ describe Braintree::Transaction do
|
|
2621
2659
|
payment_method_token = rand(36**3).to_s(36)
|
2622
2660
|
nonce = nonce_for_paypal_account(
|
2623
2661
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2624
|
-
:token => payment_method_token
|
2662
|
+
:token => payment_method_token,
|
2625
2663
|
)
|
2626
2664
|
|
2627
2665
|
result = Braintree::Transaction.create(
|
2628
2666
|
:type => "sale",
|
2629
2667
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2630
|
-
:payment_method_nonce => nonce
|
2668
|
+
:payment_method_nonce => nonce,
|
2631
2669
|
)
|
2632
2670
|
|
2633
2671
|
result.should be_success
|
@@ -2643,14 +2681,14 @@ describe Braintree::Transaction do
|
|
2643
2681
|
payment_method_token = rand(36**3).to_s(36)
|
2644
2682
|
nonce = nonce_for_paypal_account(
|
2645
2683
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
2646
|
-
:token => payment_method_token
|
2684
|
+
:token => payment_method_token,
|
2647
2685
|
)
|
2648
2686
|
|
2649
2687
|
result = Braintree::Transaction.create(
|
2650
2688
|
:type => "sale",
|
2651
2689
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2652
2690
|
:payment_method_nonce => nonce,
|
2653
|
-
:options => {:store_in_vault => true}
|
2691
|
+
:options => {:store_in_vault => true},
|
2654
2692
|
)
|
2655
2693
|
|
2656
2694
|
result.success?.should == true
|
@@ -2663,12 +2701,28 @@ describe Braintree::Transaction do
|
|
2663
2701
|
end
|
2664
2702
|
end
|
2665
2703
|
|
2704
|
+
context "billing agreement" do
|
2705
|
+
it "can create a paypal billing agreement" do
|
2706
|
+
result = Braintree::Transaction.create(
|
2707
|
+
:type => "sale",
|
2708
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2709
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
2710
|
+
:options => {:store_in_vault => true},
|
2711
|
+
)
|
2712
|
+
|
2713
|
+
result.should be_success
|
2714
|
+
result.transaction.paypal_details.should_not be_nil
|
2715
|
+
result.transaction.paypal_details.debug_id.should_not be_nil
|
2716
|
+
result.transaction.paypal_details.billing_agreement_id.should_not be_nil
|
2717
|
+
end
|
2718
|
+
end
|
2719
|
+
|
2666
2720
|
context "local payments" do
|
2667
2721
|
it "can create a local payment transaction with a nonce" do
|
2668
2722
|
result = Braintree::Transaction.create(
|
2669
2723
|
:type => "sale",
|
2670
2724
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2671
|
-
:payment_method_nonce => Braintree::Test::Nonce::LocalPayment
|
2725
|
+
:payment_method_nonce => Braintree::Test::Nonce::LocalPayment,
|
2672
2726
|
)
|
2673
2727
|
|
2674
2728
|
result.should be_success
|
@@ -2686,7 +2740,7 @@ describe Braintree::Transaction do
|
|
2686
2740
|
result = Braintree::Transaction.create(
|
2687
2741
|
:type => "sale",
|
2688
2742
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2689
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2743
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2690
2744
|
)
|
2691
2745
|
|
2692
2746
|
result.should be_success
|
@@ -2698,14 +2752,14 @@ describe Braintree::Transaction do
|
|
2698
2752
|
payment_method_token = rand(36**3).to_s(36)
|
2699
2753
|
nonce = nonce_for_paypal_account(
|
2700
2754
|
:access_token => "PAYPAL_ACCESS_TOKEN",
|
2701
|
-
:token => payment_method_token
|
2755
|
+
:token => payment_method_token,
|
2702
2756
|
)
|
2703
2757
|
|
2704
2758
|
result = Braintree::Transaction.create(
|
2705
2759
|
:type => "sale",
|
2706
2760
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2707
2761
|
:payment_method_nonce => nonce,
|
2708
|
-
:options => {:store_in_vault => true}
|
2762
|
+
:options => {:store_in_vault => true},
|
2709
2763
|
)
|
2710
2764
|
|
2711
2765
|
result.success?.should == true
|
@@ -2725,7 +2779,7 @@ describe Braintree::Transaction do
|
|
2725
2779
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2726
2780
|
:options => {
|
2727
2781
|
:submit_for_settlement => true
|
2728
|
-
}
|
2782
|
+
},
|
2729
2783
|
)
|
2730
2784
|
result.success?.should == true
|
2731
2785
|
result.transaction.status.should == Braintree::Transaction::Status::Settling
|
@@ -2736,7 +2790,7 @@ describe Braintree::Transaction do
|
|
2736
2790
|
it "successfully voids a paypal transaction that's been authorized" do
|
2737
2791
|
sale_transaction = Braintree::Transaction.sale!(
|
2738
2792
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2739
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2793
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2740
2794
|
)
|
2741
2795
|
|
2742
2796
|
void_transaction = Braintree::Transaction.void!(sale_transaction.id)
|
@@ -2747,7 +2801,7 @@ describe Braintree::Transaction do
|
|
2747
2801
|
it "fails to void a paypal transaction that's been declined" do
|
2748
2802
|
sale_transaction = Braintree::Transaction.sale(
|
2749
2803
|
:amount => Braintree::Test::TransactionAmounts::Decline,
|
2750
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2804
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2751
2805
|
).transaction
|
2752
2806
|
|
2753
2807
|
expect do
|
@@ -2817,6 +2871,19 @@ describe Braintree::Transaction do
|
|
2817
2871
|
result.transaction.amount.should == transaction.amount/2
|
2818
2872
|
end
|
2819
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
|
+
|
2820
2887
|
it "does not allow arbitrary options to be passed" do
|
2821
2888
|
transaction = create_paypal_transaction_for_refund
|
2822
2889
|
|
@@ -2835,7 +2902,7 @@ describe Braintree::Transaction do
|
|
2835
2902
|
it "returns an error result if unsettled" do
|
2836
2903
|
transaction = Braintree::Transaction.sale!(
|
2837
2904
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2838
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
2905
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
2839
2906
|
)
|
2840
2907
|
result = Braintree::Transaction.refund(transaction.id)
|
2841
2908
|
result.success?.should == false
|
@@ -2848,7 +2915,7 @@ describe Braintree::Transaction do
|
|
2848
2915
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
2849
2916
|
:options => {
|
2850
2917
|
:submit_for_settlement => true
|
2851
|
-
}
|
2918
|
+
},
|
2852
2919
|
)
|
2853
2920
|
config = Braintree::Configuration.instantiate
|
2854
2921
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
@@ -2869,7 +2936,7 @@ describe Braintree::Transaction do
|
|
2869
2936
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
2870
2937
|
:options => {
|
2871
2938
|
:submit_for_settlement => true
|
2872
|
-
}
|
2939
|
+
},
|
2873
2940
|
)
|
2874
2941
|
config = Braintree::Configuration.instantiate
|
2875
2942
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
@@ -2889,13 +2956,13 @@ describe Braintree::Transaction do
|
|
2889
2956
|
it "handles bad unvalidated nonces" do
|
2890
2957
|
nonce = nonce_for_paypal_account(
|
2891
2958
|
:access_token => "PAYPAL_ACCESS_TOKEN",
|
2892
|
-
:consent_code => "PAYPAL_CONSENT_CODE"
|
2959
|
+
:consent_code => "PAYPAL_CONSENT_CODE",
|
2893
2960
|
)
|
2894
2961
|
|
2895
2962
|
result = Braintree::Transaction.create(
|
2896
2963
|
:type => "sale",
|
2897
2964
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2898
|
-
:payment_method_nonce => nonce
|
2965
|
+
:payment_method_nonce => nonce,
|
2899
2966
|
)
|
2900
2967
|
|
2901
2968
|
result.should_not be_success
|
@@ -2906,7 +2973,7 @@ describe Braintree::Transaction do
|
|
2906
2973
|
result = Braintree::Transaction.create(
|
2907
2974
|
:type => "sale",
|
2908
2975
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2909
|
-
:payment_method_nonce => "NON_EXISTENT_NONCE"
|
2976
|
+
:payment_method_nonce => "NON_EXISTENT_NONCE",
|
2910
2977
|
)
|
2911
2978
|
|
2912
2979
|
result.should_not be_success
|
@@ -4034,7 +4101,7 @@ describe Braintree::Transaction do
|
|
4034
4101
|
:unit_of_measure => "gallon",
|
4035
4102
|
:total_amount => "10.1",
|
4036
4103
|
},
|
4037
|
-
[
|
4104
|
+
["Name #2"],
|
4038
4105
|
{
|
4039
4106
|
:quantity => "2.02",
|
4040
4107
|
:name => "Name #3",
|
@@ -4220,7 +4287,7 @@ describe Braintree::Transaction do
|
|
4220
4287
|
customer = Braintree::Customer.create!
|
4221
4288
|
result = Braintree::PaymentMethod.create(
|
4222
4289
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
4223
|
-
:customer_id => customer.id
|
4290
|
+
:customer_id => customer.id,
|
4224
4291
|
)
|
4225
4292
|
payment_method_token = result.payment_method.token
|
4226
4293
|
|
@@ -4253,7 +4320,7 @@ describe Braintree::Transaction do
|
|
4253
4320
|
result.errors.for(:transaction).for(:external_vault).on(:status)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::StatusIsInvalid
|
4254
4321
|
end
|
4255
4322
|
|
4256
|
-
context "Visa/Mastercard/Discover" do
|
4323
|
+
context "Visa/Mastercard/Discover/AmEx" do
|
4257
4324
|
it "accepts status" do
|
4258
4325
|
result = Braintree::Transaction.create(
|
4259
4326
|
:type => "sale",
|
@@ -4305,12 +4372,12 @@ describe Braintree::Transaction do
|
|
4305
4372
|
end
|
4306
4373
|
end
|
4307
4374
|
|
4308
|
-
context "Non-(Visa/Mastercard/Discover) card types" do
|
4375
|
+
context "Non-(Visa/Mastercard/Discover/AmEx) card types" do
|
4309
4376
|
it "accepts status" do
|
4310
4377
|
result = Braintree::Transaction.create(
|
4311
4378
|
:type => "sale",
|
4312
4379
|
:credit_card => {
|
4313
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4380
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4314
4381
|
:expiration_date => "05/2009"
|
4315
4382
|
},
|
4316
4383
|
:external_vault => {
|
@@ -4326,7 +4393,7 @@ describe Braintree::Transaction do
|
|
4326
4393
|
result = Braintree::Transaction.create(
|
4327
4394
|
:type => "sale",
|
4328
4395
|
:credit_card => {
|
4329
|
-
:number => Braintree::Test::CreditCardNumbers::
|
4396
|
+
:number => Braintree::Test::CreditCardNumbers::JCBs[0],
|
4330
4397
|
:expiration_date => "05/2009"
|
4331
4398
|
},
|
4332
4399
|
:external_vault => {
|
@@ -4338,25 +4405,7 @@ describe Braintree::Transaction do
|
|
4338
4405
|
result.success?.should == true
|
4339
4406
|
result.transaction.network_transaction_id.should be_nil
|
4340
4407
|
end
|
4341
|
-
|
4342
|
-
it "rejects previous_network_transaction_id" do
|
4343
|
-
result = Braintree::Transaction.create(
|
4344
|
-
:type => "sale",
|
4345
|
-
:credit_card => {
|
4346
|
-
:number => Braintree::Test::CreditCardNumbers::AmExes[0],
|
4347
|
-
:expiration_date => "05/2009"
|
4348
|
-
},
|
4349
|
-
:external_vault => {
|
4350
|
-
:status => Braintree::Transaction::ExternalVault::Status::Vaulted,
|
4351
|
-
:previous_network_transaction_id => "123456789012345",
|
4352
|
-
},
|
4353
|
-
:amount => "10.00",
|
4354
|
-
)
|
4355
|
-
result.success?.should == false
|
4356
|
-
result.errors.for(:transaction).for(:external_vault).on(:previous_network_transaction_id)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::CardTypeIsInvalid
|
4357
|
-
end
|
4358
4408
|
end
|
4359
|
-
|
4360
4409
|
end
|
4361
4410
|
|
4362
4411
|
context "account_type" do
|
@@ -4373,7 +4422,7 @@ describe Braintree::Transaction do
|
|
4373
4422
|
:credit_card => {
|
4374
4423
|
:account_type => "credit",
|
4375
4424
|
}
|
4376
|
-
}
|
4425
|
+
},
|
4377
4426
|
)
|
4378
4427
|
result.success?.should == true
|
4379
4428
|
result.transaction.credit_card_details.account_type.should == "credit"
|
@@ -4392,7 +4441,7 @@ describe Braintree::Transaction do
|
|
4392
4441
|
:credit_card => {
|
4393
4442
|
:account_type => "credit",
|
4394
4443
|
}
|
4395
|
-
}
|
4444
|
+
},
|
4396
4445
|
)
|
4397
4446
|
result.success?.should == true
|
4398
4447
|
result.transaction.credit_card_details.account_type.should == "credit"
|
@@ -4412,7 +4461,7 @@ describe Braintree::Transaction do
|
|
4412
4461
|
:account_type => "debit",
|
4413
4462
|
},
|
4414
4463
|
:submit_for_settlement => true,
|
4415
|
-
}
|
4464
|
+
},
|
4416
4465
|
)
|
4417
4466
|
result.success?.should == true
|
4418
4467
|
result.transaction.credit_card_details.account_type.should == "debit"
|
@@ -4431,7 +4480,7 @@ describe Braintree::Transaction do
|
|
4431
4480
|
:credit_card => {
|
4432
4481
|
:account_type => "debit",
|
4433
4482
|
},
|
4434
|
-
}
|
4483
|
+
},
|
4435
4484
|
)
|
4436
4485
|
result.success?.should == false
|
4437
4486
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeDebitDoesNotSupportAuths
|
@@ -4450,7 +4499,7 @@ describe Braintree::Transaction do
|
|
4450
4499
|
:credit_card => {
|
4451
4500
|
:account_type => "ach",
|
4452
4501
|
},
|
4453
|
-
}
|
4502
|
+
},
|
4454
4503
|
)
|
4455
4504
|
result.success?.should == false
|
4456
4505
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeIsInvalid
|
@@ -4468,7 +4517,7 @@ describe Braintree::Transaction do
|
|
4468
4517
|
:credit_card => {
|
4469
4518
|
:account_type => "credit",
|
4470
4519
|
},
|
4471
|
-
}
|
4520
|
+
},
|
4472
4521
|
)
|
4473
4522
|
result.success?.should == false
|
4474
4523
|
result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeNotSupported
|
@@ -4484,7 +4533,7 @@ describe Braintree::Transaction do
|
|
4484
4533
|
:credit_card => {
|
4485
4534
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4486
4535
|
:expiration_date => "05/2009"
|
4487
|
-
}
|
4536
|
+
},
|
4488
4537
|
)
|
4489
4538
|
transaction.id.should =~ /^\w{6,}$/
|
4490
4539
|
transaction.type.should == "sale"
|
@@ -4502,7 +4551,7 @@ describe Braintree::Transaction do
|
|
4502
4551
|
:credit_card => {
|
4503
4552
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4504
4553
|
:expiration_date => "05/2009"
|
4505
|
-
}
|
4554
|
+
},
|
4506
4555
|
)
|
4507
4556
|
end.to raise_error(Braintree::ValidationsFailed)
|
4508
4557
|
end
|
@@ -4558,7 +4607,7 @@ describe Braintree::Transaction do
|
|
4558
4607
|
:credit_card => {
|
4559
4608
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4560
4609
|
:expiration_date => "05/2009"
|
4561
|
-
}
|
4610
|
+
},
|
4562
4611
|
)
|
4563
4612
|
result = Braintree::Transaction.refund(transaction.id)
|
4564
4613
|
result.success?.should == false
|
@@ -4595,7 +4644,7 @@ describe Braintree::Transaction do
|
|
4595
4644
|
:credit_card => {
|
4596
4645
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4597
4646
|
:expiration_date => "05/2009"
|
4598
|
-
}
|
4647
|
+
},
|
4599
4648
|
)
|
4600
4649
|
result.success?.should == true
|
4601
4650
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -4651,7 +4700,7 @@ describe Braintree::Transaction do
|
|
4651
4700
|
:postal_code => "60103",
|
4652
4701
|
:country_name => "United States of America",
|
4653
4702
|
:shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
|
4654
|
-
}
|
4703
|
+
},
|
4655
4704
|
)
|
4656
4705
|
result.success?.should == true
|
4657
4706
|
transaction = result.transaction
|
@@ -4715,7 +4764,7 @@ describe Braintree::Transaction do
|
|
4715
4764
|
:credit_card => {
|
4716
4765
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4717
4766
|
:expiration_date => "05/2009"
|
4718
|
-
}
|
4767
|
+
},
|
4719
4768
|
)
|
4720
4769
|
result.success?.should == true
|
4721
4770
|
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -4727,7 +4776,7 @@ describe Braintree::Transaction do
|
|
4727
4776
|
:credit_card => {
|
4728
4777
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4729
4778
|
:expiration_date => "05/2009"
|
4730
|
-
}
|
4779
|
+
},
|
4731
4780
|
)
|
4732
4781
|
result.success?.should == true
|
4733
4782
|
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
|
@@ -4746,7 +4795,7 @@ describe Braintree::Transaction do
|
|
4746
4795
|
},
|
4747
4796
|
:options => {
|
4748
4797
|
:store_in_vault => true
|
4749
|
-
}
|
4798
|
+
},
|
4750
4799
|
)
|
4751
4800
|
result.success?.should == true
|
4752
4801
|
transaction = result.transaction
|
@@ -4781,7 +4830,7 @@ describe Braintree::Transaction do
|
|
4781
4830
|
:options => {
|
4782
4831
|
:store_in_vault => true,
|
4783
4832
|
:add_billing_address_to_payment_method => true,
|
4784
|
-
}
|
4833
|
+
},
|
4785
4834
|
)
|
4786
4835
|
result.success?.should == true
|
4787
4836
|
transaction = result.transaction
|
@@ -4826,7 +4875,7 @@ describe Braintree::Transaction do
|
|
4826
4875
|
:options => {
|
4827
4876
|
:store_in_vault => true,
|
4828
4877
|
:store_shipping_address_in_vault => true,
|
4829
|
-
}
|
4878
|
+
},
|
4830
4879
|
)
|
4831
4880
|
result.success?.should == true
|
4832
4881
|
transaction = result.transaction
|
@@ -4852,7 +4901,7 @@ describe Braintree::Transaction do
|
|
4852
4901
|
:number => "5105105105105100",
|
4853
4902
|
:expiration_date => "05/2012"
|
4854
4903
|
},
|
4855
|
-
:options => {
|
4904
|
+
:options => {:store_in_vault => true},
|
4856
4905
|
)
|
4857
4906
|
|
4858
4907
|
result.success?.should == true
|
@@ -4870,7 +4919,7 @@ describe Braintree::Transaction do
|
|
4870
4919
|
},
|
4871
4920
|
:options => {
|
4872
4921
|
:submit_for_settlement => true
|
4873
|
-
}
|
4922
|
+
},
|
4874
4923
|
)
|
4875
4924
|
result.success?.should == true
|
4876
4925
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -4893,7 +4942,7 @@ describe Braintree::Transaction do
|
|
4893
4942
|
},
|
4894
4943
|
:options => {
|
4895
4944
|
:store_in_vault => true
|
4896
|
-
}
|
4945
|
+
},
|
4897
4946
|
)
|
4898
4947
|
result.success?.should == true
|
4899
4948
|
transaction = result.transaction
|
@@ -4908,20 +4957,20 @@ describe Braintree::Transaction do
|
|
4908
4957
|
:credit_card => {
|
4909
4958
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
4910
4959
|
:expiration_date => "05/2010"
|
4911
|
-
}
|
4960
|
+
},
|
4912
4961
|
)
|
4913
4962
|
address = Braintree::Address.create!(
|
4914
4963
|
:customer_id => customer.id,
|
4915
|
-
:street_address =>
|
4964
|
+
:street_address => "123 Fake St.",
|
4916
4965
|
)
|
4917
4966
|
result = Braintree::Transaction.sale(
|
4918
4967
|
:amount => "100",
|
4919
4968
|
:customer_id => customer.id,
|
4920
|
-
:shipping_address_id => address.id
|
4969
|
+
:shipping_address_id => address.id,
|
4921
4970
|
)
|
4922
4971
|
result.success?.should == true
|
4923
4972
|
transaction = result.transaction
|
4924
|
-
transaction.shipping_details.street_address.should ==
|
4973
|
+
transaction.shipping_details.street_address.should == "123 Fake St."
|
4925
4974
|
transaction.customer_details.id.should == customer.id
|
4926
4975
|
transaction.shipping_details.id.should == address.id
|
4927
4976
|
end
|
@@ -4938,12 +4987,79 @@ describe Braintree::Transaction do
|
|
4938
4987
|
}
|
4939
4988
|
result = Braintree::Transaction.sale(params[:transaction])
|
4940
4989
|
result.success?.should == false
|
4941
|
-
result.params.should == {:transaction => {:type =>
|
4990
|
+
result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
4942
4991
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
4943
4992
|
end
|
4944
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
|
+
|
4945
5061
|
it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
|
4946
|
-
|
5062
|
+
with_advanced_fraud_kount_integration_merchant do
|
4947
5063
|
result = Braintree::Transaction.sale(
|
4948
5064
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
4949
5065
|
:credit_card => {
|
@@ -4952,7 +5068,7 @@ describe Braintree::Transaction do
|
|
4952
5068
|
},
|
4953
5069
|
:options => {
|
4954
5070
|
:skip_advanced_fraud_checking => true
|
4955
|
-
}
|
5071
|
+
},
|
4956
5072
|
)
|
4957
5073
|
result.success?.should == true
|
4958
5074
|
result.transaction.risk_data.should be_nil
|
@@ -5046,7 +5162,7 @@ describe Braintree::Transaction do
|
|
5046
5162
|
:currency_amount => "10.00",
|
5047
5163
|
:currency_iso_code => "USD"
|
5048
5164
|
}
|
5049
|
-
}
|
5165
|
+
},
|
5050
5166
|
)
|
5051
5167
|
result.success?.should == true
|
5052
5168
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5068,7 +5184,7 @@ describe Braintree::Transaction do
|
|
5068
5184
|
:currency_amount => "10.00",
|
5069
5185
|
:currency_iso_code => "USD"
|
5070
5186
|
}
|
5071
|
-
}
|
5187
|
+
},
|
5072
5188
|
)
|
5073
5189
|
result.success?.should == true
|
5074
5190
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5090,7 +5206,7 @@ describe Braintree::Transaction do
|
|
5090
5206
|
:currency_amount => "10.00",
|
5091
5207
|
:currency_iso_code => "USD"
|
5092
5208
|
}
|
5093
|
-
}
|
5209
|
+
},
|
5094
5210
|
)
|
5095
5211
|
result.success?.should == true
|
5096
5212
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5113,7 +5229,7 @@ describe Braintree::Transaction do
|
|
5113
5229
|
:currency_amount => "10.00",
|
5114
5230
|
:currency_iso_code => "USD"
|
5115
5231
|
}
|
5116
|
-
}
|
5232
|
+
},
|
5117
5233
|
)
|
5118
5234
|
result.success?.should == true
|
5119
5235
|
|
@@ -5137,7 +5253,7 @@ describe Braintree::Transaction do
|
|
5137
5253
|
:currency_amount => "10.00",
|
5138
5254
|
:currency_iso_code => "USD"
|
5139
5255
|
}
|
5140
|
-
}
|
5256
|
+
},
|
5141
5257
|
)
|
5142
5258
|
result.success?.should == true
|
5143
5259
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
@@ -5162,7 +5278,7 @@ describe Braintree::Transaction do
|
|
5162
5278
|
:currency_amount => "10.00",
|
5163
5279
|
:currency_iso_code => "USD"
|
5164
5280
|
}
|
5165
|
-
}
|
5281
|
+
},
|
5166
5282
|
)
|
5167
5283
|
result.success?.should == true
|
5168
5284
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
@@ -5182,7 +5298,7 @@ describe Braintree::Transaction do
|
|
5182
5298
|
:credit_card => {
|
5183
5299
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5184
5300
|
:expiration_date => "05/2009"
|
5185
|
-
}
|
5301
|
+
},
|
5186
5302
|
)
|
5187
5303
|
transaction.id.should =~ /^\w{6,}$/
|
5188
5304
|
transaction.type.should == "sale"
|
@@ -5199,7 +5315,7 @@ describe Braintree::Transaction do
|
|
5199
5315
|
:credit_card => {
|
5200
5316
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5201
5317
|
:expiration_date => "05/2009"
|
5202
|
-
}
|
5318
|
+
},
|
5203
5319
|
)
|
5204
5320
|
end.to raise_error(Braintree::ValidationsFailed)
|
5205
5321
|
end
|
@@ -5212,7 +5328,7 @@ describe Braintree::Transaction do
|
|
5212
5328
|
:credit_card => {
|
5213
5329
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5214
5330
|
:expiration_date => "06/2009"
|
5215
|
-
}
|
5331
|
+
},
|
5216
5332
|
)
|
5217
5333
|
result = Braintree::Transaction.submit_for_settlement(transaction.id)
|
5218
5334
|
result.success?.should == true
|
@@ -5224,7 +5340,7 @@ describe Braintree::Transaction do
|
|
5224
5340
|
:credit_card => {
|
5225
5341
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5226
5342
|
:expiration_date => "06/2009"
|
5227
|
-
}
|
5343
|
+
},
|
5228
5344
|
)
|
5229
5345
|
transaction.amount.should == BigDecimal("1000.00")
|
5230
5346
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "999.99")
|
@@ -5240,9 +5356,9 @@ describe Braintree::Transaction do
|
|
5240
5356
|
:credit_card => {
|
5241
5357
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5242
5358
|
:expiration_date => "06/2009"
|
5243
|
-
}
|
5359
|
+
},
|
5244
5360
|
)
|
5245
|
-
options = {
|
5361
|
+
options = {:order_id => "ABC123"}
|
5246
5362
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
5247
5363
|
result.success?.should == true
|
5248
5364
|
result.transaction.order_id.should == "ABC123"
|
@@ -5255,13 +5371,13 @@ describe Braintree::Transaction do
|
|
5255
5371
|
:credit_card => {
|
5256
5372
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5257
5373
|
:expiration_date => "06/2009"
|
5258
|
-
}
|
5374
|
+
},
|
5259
5375
|
)
|
5260
5376
|
|
5261
5377
|
options = {
|
5262
5378
|
:descriptor => {
|
5263
|
-
:name =>
|
5264
|
-
:phone =>
|
5379
|
+
:name => "123*123456789012345678",
|
5380
|
+
:phone => "3334445555",
|
5265
5381
|
:url => "ebay.com"
|
5266
5382
|
}
|
5267
5383
|
}
|
@@ -5269,9 +5385,9 @@ describe Braintree::Transaction do
|
|
5269
5385
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
5270
5386
|
result.success?.should == true
|
5271
5387
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5272
|
-
result.transaction.descriptor.name.should ==
|
5273
|
-
result.transaction.descriptor.phone.should ==
|
5274
|
-
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"
|
5275
5391
|
end
|
5276
5392
|
|
5277
5393
|
it "raises an error if an invalid option is passed in" do
|
@@ -5280,10 +5396,10 @@ describe Braintree::Transaction do
|
|
5280
5396
|
:credit_card => {
|
5281
5397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5282
5398
|
:expiration_date => "06/2009"
|
5283
|
-
}
|
5399
|
+
},
|
5284
5400
|
)
|
5285
5401
|
|
5286
|
-
options = {
|
5402
|
+
options = {:order_id => "ABC123", :invalid_option => "i'm invalid"}
|
5287
5403
|
|
5288
5404
|
expect do
|
5289
5405
|
Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
|
@@ -5293,10 +5409,11 @@ describe Braintree::Transaction do
|
|
5293
5409
|
it "returns an error result if settlement is too large" do
|
5294
5410
|
transaction = Braintree::Transaction.sale!(
|
5295
5411
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5412
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
5296
5413
|
:credit_card => {
|
5297
5414
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5298
5415
|
:expiration_date => "06/2009"
|
5299
|
-
}
|
5416
|
+
},
|
5300
5417
|
)
|
5301
5418
|
transaction.amount.should == BigDecimal("1000.00")
|
5302
5419
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "1000.01")
|
@@ -5311,7 +5428,7 @@ describe Braintree::Transaction do
|
|
5311
5428
|
:credit_card => {
|
5312
5429
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5313
5430
|
:expiration_date => "06/2009"
|
5314
|
-
}
|
5431
|
+
},
|
5315
5432
|
).transaction
|
5316
5433
|
result = Braintree::Transaction.submit_for_settlement(transaction.id)
|
5317
5434
|
result.success?.should == false
|
@@ -5328,7 +5445,7 @@ describe Braintree::Transaction do
|
|
5328
5445
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5329
5446
|
:expiration_date => "06/2009"
|
5330
5447
|
},
|
5331
|
-
:service_fee_amount => "1.00"
|
5448
|
+
:service_fee_amount => "1.00",
|
5332
5449
|
).transaction
|
5333
5450
|
result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
|
5334
5451
|
result.success?.should == false
|
@@ -5351,7 +5468,7 @@ describe Braintree::Transaction do
|
|
5351
5468
|
:currency_amount => "10.00",
|
5352
5469
|
:currency_iso_code => "USD"
|
5353
5470
|
}
|
5354
|
-
}
|
5471
|
+
},
|
5355
5472
|
)
|
5356
5473
|
result.success?.should == true
|
5357
5474
|
|
@@ -5375,7 +5492,7 @@ describe Braintree::Transaction do
|
|
5375
5492
|
:currency_amount => "10.00",
|
5376
5493
|
:currency_iso_code => "USD"
|
5377
5494
|
}
|
5378
|
-
}
|
5495
|
+
},
|
5379
5496
|
)
|
5380
5497
|
result.success?.should == true
|
5381
5498
|
|
@@ -5395,7 +5512,7 @@ describe Braintree::Transaction do
|
|
5395
5512
|
:discount_amount => "12.00",
|
5396
5513
|
:tax_amount => "0",
|
5397
5514
|
},
|
5398
|
-
]
|
5515
|
+
],
|
5399
5516
|
)
|
5400
5517
|
result.success?.should == true
|
5401
5518
|
result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
@@ -5409,9 +5526,9 @@ describe Braintree::Transaction do
|
|
5409
5526
|
:credit_card => {
|
5410
5527
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5411
5528
|
:expiration_date => "06/2009"
|
5412
|
-
}
|
5529
|
+
},
|
5413
5530
|
)
|
5414
|
-
options = {
|
5531
|
+
options = {:order_id => "ABC123"}
|
5415
5532
|
transaction = Braintree::Transaction.submit_for_settlement!(original_transaction.id, "0.01", options)
|
5416
5533
|
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5417
5534
|
transaction.id.should == original_transaction.id
|
@@ -5421,10 +5538,11 @@ describe Braintree::Transaction do
|
|
5421
5538
|
it "raises a ValidationsFailed if unsuccessful" do
|
5422
5539
|
transaction = Braintree::Transaction.sale!(
|
5423
5540
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5541
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
5424
5542
|
:credit_card => {
|
5425
5543
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5426
5544
|
:expiration_date => "06/2009"
|
5427
|
-
}
|
5545
|
+
},
|
5428
5546
|
)
|
5429
5547
|
transaction.amount.should == BigDecimal("1000.00")
|
5430
5548
|
expect do
|
@@ -5440,18 +5558,18 @@ describe Braintree::Transaction do
|
|
5440
5558
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5441
5559
|
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
5442
5560
|
:descriptor => {
|
5443
|
-
:name =>
|
5444
|
-
:phone =>
|
5561
|
+
:name => "123*123456789012345678",
|
5562
|
+
:phone => "3334445555",
|
5445
5563
|
:url => "ebay.com"
|
5446
5564
|
},
|
5447
|
-
:order_id =>
|
5565
|
+
:order_id => "123",
|
5448
5566
|
:credit_card => {
|
5449
5567
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5450
5568
|
:expiration_date => "06/2009"
|
5451
5569
|
},
|
5452
5570
|
:options => {
|
5453
5571
|
:submit_for_settlement => true
|
5454
|
-
}
|
5572
|
+
},
|
5455
5573
|
)
|
5456
5574
|
end
|
5457
5575
|
|
@@ -5459,16 +5577,16 @@ describe Braintree::Transaction do
|
|
5459
5577
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5460
5578
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5461
5579
|
:descriptor => {
|
5462
|
-
:name =>
|
5463
|
-
:phone =>
|
5580
|
+
:name => "456*123456789012345678",
|
5581
|
+
:phone => "3334445555",
|
5464
5582
|
:url => "ebay.com",
|
5465
5583
|
},
|
5466
|
-
:order_id =>
|
5584
|
+
:order_id => "456"
|
5467
5585
|
})
|
5468
5586
|
result.success?.should == true
|
5469
5587
|
result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize) - 1
|
5470
|
-
result.transaction.order_id.should ==
|
5471
|
-
result.transaction.descriptor.name.should ==
|
5588
|
+
result.transaction.order_id.should == "456"
|
5589
|
+
result.transaction.descriptor.name.should == "456*123456789012345678"
|
5472
5590
|
end
|
5473
5591
|
|
5474
5592
|
it "raises an error when a key is invalid" do
|
@@ -5476,11 +5594,11 @@ describe Braintree::Transaction do
|
|
5476
5594
|
Braintree::Transaction.update_details(transaction.id, {
|
5477
5595
|
:invalid_key => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5478
5596
|
:descriptor => {
|
5479
|
-
:name =>
|
5480
|
-
:phone =>
|
5597
|
+
:name => "456*123456789012345678",
|
5598
|
+
:phone => "3334445555",
|
5481
5599
|
:url => "ebay.com",
|
5482
5600
|
},
|
5483
|
-
:order_id =>
|
5601
|
+
:order_id => "456"
|
5484
5602
|
})
|
5485
5603
|
end.to raise_error(ArgumentError)
|
5486
5604
|
end
|
@@ -5490,11 +5608,11 @@ describe Braintree::Transaction do
|
|
5490
5608
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5491
5609
|
:amount => "10000",
|
5492
5610
|
:descriptor => {
|
5493
|
-
:name =>
|
5494
|
-
:phone =>
|
5611
|
+
:name => "456*123456789012345678",
|
5612
|
+
:phone => "3334445555",
|
5495
5613
|
:url => "ebay.com",
|
5496
5614
|
},
|
5497
|
-
:order_id =>
|
5615
|
+
:order_id => "456"
|
5498
5616
|
})
|
5499
5617
|
result.success?.should == false
|
5500
5618
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
|
@@ -5504,11 +5622,11 @@ describe Braintree::Transaction do
|
|
5504
5622
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5505
5623
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5506
5624
|
:descriptor => {
|
5507
|
-
:name =>
|
5508
|
-
:phone =>
|
5509
|
-
:url =>
|
5625
|
+
:name => "invalid descriptor name",
|
5626
|
+
:phone => "invalid phone",
|
5627
|
+
:url => "12345678901234"
|
5510
5628
|
},
|
5511
|
-
:order_id =>
|
5629
|
+
:order_id => "456"
|
5512
5630
|
})
|
5513
5631
|
result.success?.should == false
|
5514
5632
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -5520,11 +5638,11 @@ describe Braintree::Transaction do
|
|
5520
5638
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5521
5639
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5522
5640
|
:descriptor => {
|
5523
|
-
:name =>
|
5524
|
-
:phone =>
|
5641
|
+
:name => "456*123456789012345678",
|
5642
|
+
:phone => "3334445555",
|
5525
5643
|
:url => "ebay.com",
|
5526
5644
|
},
|
5527
|
-
:order_id =>
|
5645
|
+
:order_id => "x" * 256
|
5528
5646
|
})
|
5529
5647
|
result.success?.should == false
|
5530
5648
|
result.errors.for(:transaction).on(:order_id)[0].code.should == Braintree::ErrorCodes::Transaction::OrderIdIsTooLong
|
@@ -5535,27 +5653,27 @@ describe Braintree::Transaction do
|
|
5535
5653
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5536
5654
|
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
5537
5655
|
:descriptor => {
|
5538
|
-
:name =>
|
5539
|
-
:phone =>
|
5656
|
+
:name => "123*123456789012345678",
|
5657
|
+
:phone => "3334445555",
|
5540
5658
|
:url => "ebay.com"
|
5541
5659
|
},
|
5542
|
-
:order_id =>
|
5660
|
+
:order_id => "123",
|
5543
5661
|
:credit_card => {
|
5544
5662
|
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5545
5663
|
:expiration_date => "05/2009"
|
5546
5664
|
},
|
5547
5665
|
:options => {
|
5548
5666
|
:submit_for_settlement => true
|
5549
|
-
}
|
5667
|
+
},
|
5550
5668
|
)
|
5551
5669
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5552
5670
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5553
5671
|
:descriptor => {
|
5554
|
-
:name =>
|
5555
|
-
:phone =>
|
5672
|
+
:name => "456*123456789012345678",
|
5673
|
+
:phone => "3334445555",
|
5556
5674
|
:url => "ebay.com",
|
5557
5675
|
},
|
5558
|
-
:order_id =>
|
5676
|
+
:order_id => "456"
|
5559
5677
|
})
|
5560
5678
|
result.success?.should == false
|
5561
5679
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportUpdatingTransactionDetails
|
@@ -5569,24 +5687,24 @@ describe Braintree::Transaction do
|
|
5569
5687
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5570
5688
|
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
5571
5689
|
:descriptor => {
|
5572
|
-
:name =>
|
5573
|
-
:phone =>
|
5690
|
+
:name => "123*123456789012345678",
|
5691
|
+
:phone => "3334445555",
|
5574
5692
|
:url => "ebay.com"
|
5575
5693
|
},
|
5576
|
-
:order_id =>
|
5694
|
+
:order_id => "123",
|
5577
5695
|
:credit_card => {
|
5578
5696
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5579
5697
|
:expiration_date => "06/2009"
|
5580
|
-
}
|
5698
|
+
},
|
5581
5699
|
)
|
5582
5700
|
result = Braintree::Transaction.update_details(transaction.id, {
|
5583
5701
|
:amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
|
5584
5702
|
:descriptor => {
|
5585
|
-
:name =>
|
5586
|
-
:phone =>
|
5703
|
+
:name => "456*123456789012345678",
|
5704
|
+
:phone => "3334445555",
|
5587
5705
|
:url => "ebay.com",
|
5588
5706
|
},
|
5589
|
-
:order_id =>
|
5707
|
+
:order_id => "456"
|
5590
5708
|
})
|
5591
5709
|
result.success?.should == false
|
5592
5710
|
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotUpdateTransactionDetailsNotSubmittedForSettlement
|
@@ -5603,7 +5721,7 @@ describe Braintree::Transaction do
|
|
5603
5721
|
:credit_card => {
|
5604
5722
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5605
5723
|
:expiration_date => "06/2009"
|
5606
|
-
}
|
5724
|
+
},
|
5607
5725
|
)
|
5608
5726
|
|
5609
5727
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5638,7 +5756,7 @@ describe Braintree::Transaction do
|
|
5638
5756
|
:credit_card => {
|
5639
5757
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5640
5758
|
:expiration_date => "05/2009"
|
5641
|
-
}
|
5759
|
+
},
|
5642
5760
|
)
|
5643
5761
|
|
5644
5762
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => 1234)
|
@@ -5654,7 +5772,7 @@ describe Braintree::Transaction do
|
|
5654
5772
|
:credit_card => {
|
5655
5773
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5656
5774
|
:expiration_date => "05/2009"
|
5657
|
-
}
|
5775
|
+
},
|
5658
5776
|
)
|
5659
5777
|
|
5660
5778
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => "1"*256)
|
@@ -5669,13 +5787,13 @@ describe Braintree::Transaction do
|
|
5669
5787
|
:credit_card => {
|
5670
5788
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5671
5789
|
:expiration_date => "05/2009"
|
5672
|
-
}
|
5790
|
+
},
|
5673
5791
|
)
|
5674
5792
|
|
5675
5793
|
result = Braintree::Transaction.submit_for_partial_settlement(
|
5676
5794
|
authorized_transaction.id,
|
5677
5795
|
100,
|
5678
|
-
:descriptor => {
|
5796
|
+
:descriptor => {:name => "123*123456789012345678", :phone => "5555551234", :url => "url.com"},
|
5679
5797
|
)
|
5680
5798
|
result.success?.should == true
|
5681
5799
|
partial_settlement_transaction = result.transaction
|
@@ -5691,7 +5809,7 @@ describe Braintree::Transaction do
|
|
5691
5809
|
:credit_card => {
|
5692
5810
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5693
5811
|
:expiration_date => "05/2009"
|
5694
|
-
}
|
5812
|
+
},
|
5695
5813
|
)
|
5696
5814
|
|
5697
5815
|
result = Braintree::Transaction.submit_for_partial_settlement(
|
@@ -5699,9 +5817,9 @@ describe Braintree::Transaction do
|
|
5699
5817
|
100,
|
5700
5818
|
:descriptor => {
|
5701
5819
|
:name => "invalid_format",
|
5702
|
-
:phone =>
|
5703
|
-
:url =>
|
5704
|
-
}
|
5820
|
+
:phone => "%bad4445555",
|
5821
|
+
:url => "12345678901234"
|
5822
|
+
},
|
5705
5823
|
)
|
5706
5824
|
result.success?.should == false
|
5707
5825
|
result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -5716,7 +5834,7 @@ describe Braintree::Transaction do
|
|
5716
5834
|
:credit_card => {
|
5717
5835
|
:number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
|
5718
5836
|
:expiration_date => "05/2009"
|
5719
|
-
}
|
5837
|
+
},
|
5720
5838
|
)
|
5721
5839
|
|
5722
5840
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5728,7 +5846,7 @@ describe Braintree::Transaction do
|
|
5728
5846
|
authorized_transaction = Braintree::Transaction.sale!(
|
5729
5847
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5730
5848
|
:merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
|
5731
|
-
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
|
5849
|
+
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
5732
5850
|
)
|
5733
5851
|
|
5734
5852
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5743,7 +5861,7 @@ describe Braintree::Transaction do
|
|
5743
5861
|
:credit_card => {
|
5744
5862
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5745
5863
|
:expiration_date => "06/2009"
|
5746
|
-
}
|
5864
|
+
},
|
5747
5865
|
)
|
5748
5866
|
|
5749
5867
|
result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
|
@@ -5761,7 +5879,7 @@ describe Braintree::Transaction do
|
|
5761
5879
|
:credit_card => {
|
5762
5880
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5763
5881
|
:expiration_date => "06/2009"
|
5764
|
-
}
|
5882
|
+
},
|
5765
5883
|
)
|
5766
5884
|
|
5767
5885
|
result = Braintree::Transaction.void(authorized_transaction.id)
|
@@ -5780,9 +5898,9 @@ describe Braintree::Transaction do
|
|
5780
5898
|
:credit_card => {
|
5781
5899
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5782
5900
|
:expiration_date => "06/2009"
|
5783
|
-
}
|
5901
|
+
},
|
5784
5902
|
)
|
5785
|
-
options = {
|
5903
|
+
options = {:order_id => "ABC123"}
|
5786
5904
|
transaction = Braintree::Transaction.submit_for_partial_settlement!(original_transaction.id, "0.01", options)
|
5787
5905
|
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
5788
5906
|
transaction.order_id.should == options[:order_id]
|
@@ -5794,7 +5912,7 @@ describe Braintree::Transaction do
|
|
5794
5912
|
:credit_card => {
|
5795
5913
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5796
5914
|
:expiration_date => "06/2009"
|
5797
|
-
}
|
5915
|
+
},
|
5798
5916
|
)
|
5799
5917
|
transaction.amount.should == BigDecimal("1000.00")
|
5800
5918
|
expect do
|
@@ -5819,7 +5937,7 @@ describe Braintree::Transaction do
|
|
5819
5937
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5820
5938
|
:expiration_date => "05/2009"
|
5821
5939
|
},
|
5822
|
-
:service_fee_amount =>
|
5940
|
+
:service_fee_amount => "1.00",
|
5823
5941
|
)
|
5824
5942
|
|
5825
5943
|
transaction.escrow_status.should be_nil
|
@@ -5845,7 +5963,7 @@ describe Braintree::Transaction do
|
|
5845
5963
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5846
5964
|
:expiration_date => "05/2009"
|
5847
5965
|
},
|
5848
|
-
:service_fee_amount =>
|
5966
|
+
:service_fee_amount => "1.00",
|
5849
5967
|
)
|
5850
5968
|
|
5851
5969
|
transaction.escrow_status.should be_nil
|
@@ -5905,7 +6023,7 @@ describe Braintree::Transaction do
|
|
5905
6023
|
:credit_card => {
|
5906
6024
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5907
6025
|
:expiration_date => "05/2009"
|
5908
|
-
}
|
6026
|
+
},
|
5909
6027
|
)
|
5910
6028
|
result.success?.should == true
|
5911
6029
|
result.transaction.id.should =~ /^\w{6,}$/
|
@@ -5928,7 +6046,7 @@ describe Braintree::Transaction do
|
|
5928
6046
|
}
|
5929
6047
|
result = Braintree::Transaction.credit(params[:transaction])
|
5930
6048
|
result.success?.should == false
|
5931
|
-
result.params.should == {:transaction => {:type =>
|
6049
|
+
result.params.should == {:transaction => {:type => "credit", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
|
5932
6050
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
5933
6051
|
end
|
5934
6052
|
|
@@ -5939,7 +6057,7 @@ describe Braintree::Transaction do
|
|
5939
6057
|
:credit_card => {
|
5940
6058
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5941
6059
|
:expiration_date => "05/2009"
|
5942
|
-
}
|
6060
|
+
},
|
5943
6061
|
)
|
5944
6062
|
result.success?.should == true
|
5945
6063
|
result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -5951,7 +6069,7 @@ describe Braintree::Transaction do
|
|
5951
6069
|
:credit_card => {
|
5952
6070
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5953
6071
|
:expiration_date => "05/2009"
|
5954
|
-
}
|
6072
|
+
},
|
5955
6073
|
)
|
5956
6074
|
result.success?.should == true
|
5957
6075
|
result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
|
@@ -5981,7 +6099,7 @@ describe Braintree::Transaction do
|
|
5981
6099
|
:credit_card => {
|
5982
6100
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5983
6101
|
:expiration_date => "05/2009"
|
5984
|
-
}
|
6102
|
+
},
|
5985
6103
|
)
|
5986
6104
|
transaction.id.should =~ /^\w{6,}$/
|
5987
6105
|
transaction.type.should == "credit"
|
@@ -5998,7 +6116,7 @@ describe Braintree::Transaction do
|
|
5998
6116
|
:credit_card => {
|
5999
6117
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6000
6118
|
:expiration_date => "05/2009"
|
6001
|
-
}
|
6119
|
+
},
|
6002
6120
|
)
|
6003
6121
|
end.to raise_error(Braintree::ValidationsFailed)
|
6004
6122
|
end
|
@@ -6012,7 +6130,7 @@ describe Braintree::Transaction do
|
|
6012
6130
|
:credit_card => {
|
6013
6131
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6014
6132
|
:expiration_date => "05/2009"
|
6015
|
-
}
|
6133
|
+
},
|
6016
6134
|
)
|
6017
6135
|
result.success?.should == true
|
6018
6136
|
created_transaction = result.transaction
|
@@ -6029,7 +6147,7 @@ describe Braintree::Transaction do
|
|
6029
6147
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6030
6148
|
:expiration_date => "05/2009"
|
6031
6149
|
},
|
6032
|
-
:options => {
|
6150
|
+
:options => {:store_in_vault => true},
|
6033
6151
|
)
|
6034
6152
|
result.success?.should == true
|
6035
6153
|
created_transaction = result.transaction
|
@@ -6045,6 +6163,12 @@ describe Braintree::Transaction do
|
|
6045
6163
|
end.to raise_error(Braintree::NotFoundError, 'transaction with id "invalid-id" not found')
|
6046
6164
|
end
|
6047
6165
|
|
6166
|
+
it "finds a transaction and returns an acquirer_reference_number if the transaction has one" do
|
6167
|
+
transaction = Braintree::Transaction.find("transactionwithacquirerreferencenumber")
|
6168
|
+
|
6169
|
+
transaction.acquirer_reference_number.should == "123456789 091019"
|
6170
|
+
end
|
6171
|
+
|
6048
6172
|
context "disbursement_details" do
|
6049
6173
|
it "includes disbursement_details on found transactions" do
|
6050
6174
|
found_transaction = Braintree::Transaction.find("deposittransaction")
|
@@ -6068,7 +6192,7 @@ describe Braintree::Transaction do
|
|
6068
6192
|
:credit_card => {
|
6069
6193
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6070
6194
|
:expiration_date => "05/2009"
|
6071
|
-
}
|
6195
|
+
},
|
6072
6196
|
)
|
6073
6197
|
result.success?.should == true
|
6074
6198
|
created_transaction = result.transaction
|
@@ -6118,7 +6242,7 @@ describe Braintree::Transaction do
|
|
6118
6242
|
:credit_card => {
|
6119
6243
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6120
6244
|
:expiration_date => "05/2009"
|
6121
|
-
}
|
6245
|
+
},
|
6122
6246
|
)
|
6123
6247
|
result.success?.should == true
|
6124
6248
|
created_transaction = result.transaction
|
@@ -6131,15 +6255,21 @@ describe Braintree::Transaction do
|
|
6131
6255
|
it "returns all the three_d_secure_info" do
|
6132
6256
|
transaction = Braintree::Transaction.find("threedsecuredtransaction")
|
6133
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"
|
6134
6265
|
transaction.three_d_secure_info.enrolled.should == "Y"
|
6135
|
-
transaction.three_d_secure_info.should
|
6266
|
+
transaction.three_d_secure_info.pares_status.should == "Y"
|
6136
6267
|
transaction.three_d_secure_info.should be_liability_shift_possible
|
6268
|
+
transaction.three_d_secure_info.should be_liability_shifted
|
6137
6269
|
transaction.three_d_secure_info.status.should == "authenticate_successful"
|
6138
|
-
transaction.three_d_secure_info.
|
6139
|
-
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6140
|
-
transaction.three_d_secure_info.eci_flag.should == "07"
|
6270
|
+
expect(transaction.three_d_secure_info.three_d_secure_authentication_id).to be
|
6141
6271
|
transaction.three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
6142
|
-
transaction.three_d_secure_info.
|
6272
|
+
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6143
6273
|
end
|
6144
6274
|
|
6145
6275
|
it "is nil if the transaction wasn't 3d secured" do
|
@@ -6181,7 +6311,7 @@ describe Braintree::Transaction do
|
|
6181
6311
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6182
6312
|
:expiration_date => "12/12",
|
6183
6313
|
},
|
6184
|
-
:service_fee_amount => "10.00"
|
6314
|
+
:service_fee_amount => "10.00",
|
6185
6315
|
)
|
6186
6316
|
|
6187
6317
|
result.transaction.escrow_status.should be_nil
|
@@ -6198,7 +6328,7 @@ describe Braintree::Transaction do
|
|
6198
6328
|
:credit_card => {
|
6199
6329
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6200
6330
|
:expiration_date => "05/2009"
|
6201
|
-
}
|
6331
|
+
},
|
6202
6332
|
)
|
6203
6333
|
|
6204
6334
|
result = Braintree::Transaction.hold_in_escrow(transaction.id)
|
@@ -6216,7 +6346,7 @@ describe Braintree::Transaction do
|
|
6216
6346
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6217
6347
|
:expiration_date => "12/12",
|
6218
6348
|
},
|
6219
|
-
:service_fee_amount => "10.00"
|
6349
|
+
:service_fee_amount => "10.00",
|
6220
6350
|
)
|
6221
6351
|
|
6222
6352
|
result.transaction.escrow_status.should be_nil
|
@@ -6232,7 +6362,7 @@ describe Braintree::Transaction do
|
|
6232
6362
|
:credit_card => {
|
6233
6363
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6234
6364
|
:expiration_date => "05/2009"
|
6235
|
-
}
|
6365
|
+
},
|
6236
6366
|
)
|
6237
6367
|
|
6238
6368
|
expect do
|
@@ -6248,7 +6378,7 @@ describe Braintree::Transaction do
|
|
6248
6378
|
:credit_card => {
|
6249
6379
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6250
6380
|
:expiration_date => "05/2009"
|
6251
|
-
}
|
6381
|
+
},
|
6252
6382
|
)
|
6253
6383
|
result = Braintree::Transaction.void(transaction.id)
|
6254
6384
|
result.success?.should == true
|
@@ -6262,7 +6392,7 @@ describe Braintree::Transaction do
|
|
6262
6392
|
:credit_card => {
|
6263
6393
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6264
6394
|
:expiration_date => "05/2009"
|
6265
|
-
}
|
6395
|
+
},
|
6266
6396
|
).transaction
|
6267
6397
|
result = Braintree::Transaction.void(transaction.id)
|
6268
6398
|
result.success?.should == false
|
@@ -6277,7 +6407,7 @@ describe Braintree::Transaction do
|
|
6277
6407
|
:credit_card => {
|
6278
6408
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6279
6409
|
:expiration_date => "05/2009"
|
6280
|
-
}
|
6410
|
+
},
|
6281
6411
|
)
|
6282
6412
|
returned_transaction = Braintree::Transaction.void!(transaction.id)
|
6283
6413
|
returned_transaction.should == transaction
|
@@ -6290,7 +6420,7 @@ describe Braintree::Transaction do
|
|
6290
6420
|
:credit_card => {
|
6291
6421
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6292
6422
|
:expiration_date => "05/2009"
|
6293
|
-
}
|
6423
|
+
},
|
6294
6424
|
).transaction
|
6295
6425
|
expect do
|
6296
6426
|
Braintree::Transaction.void!(transaction.id)
|
@@ -6305,7 +6435,7 @@ describe Braintree::Transaction do
|
|
6305
6435
|
:credit_card => {
|
6306
6436
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6307
6437
|
:expiration_date => "05/2009"
|
6308
|
-
}
|
6438
|
+
},
|
6309
6439
|
)
|
6310
6440
|
result = Braintree::Transaction.submit_for_settlement!(transaction.id)
|
6311
6441
|
result.status_history.size.should == 2
|
@@ -6363,7 +6493,7 @@ describe Braintree::Transaction do
|
|
6363
6493
|
:credit_card => {
|
6364
6494
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6365
6495
|
:expiration_date => "05/2010"
|
6366
|
-
}
|
6496
|
+
},
|
6367
6497
|
)
|
6368
6498
|
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, {:amount => "100.00"}).transaction
|
6369
6499
|
transaction.vault_credit_card.should == customer.credit_cards[0]
|
@@ -6376,7 +6506,7 @@ describe Braintree::Transaction do
|
|
6376
6506
|
:credit_card => {
|
6377
6507
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6378
6508
|
:expiration_date => "05/2010"
|
6379
|
-
}
|
6509
|
+
},
|
6380
6510
|
)
|
6381
6511
|
transaction.vault_credit_card.should == nil
|
6382
6512
|
end
|
@@ -6388,7 +6518,7 @@ describe Braintree::Transaction do
|
|
6388
6518
|
:credit_card => {
|
6389
6519
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6390
6520
|
:expiration_date => "05/2010"
|
6391
|
-
}
|
6521
|
+
},
|
6392
6522
|
)
|
6393
6523
|
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00").transaction
|
6394
6524
|
transaction.vault_customer.should == customer
|
@@ -6401,7 +6531,7 @@ describe Braintree::Transaction do
|
|
6401
6531
|
:credit_card => {
|
6402
6532
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6403
6533
|
:expiration_date => "05/2010"
|
6404
|
-
}
|
6534
|
+
},
|
6405
6535
|
)
|
6406
6536
|
transaction.vault_customer.should == nil
|
6407
6537
|
end
|
@@ -6416,7 +6546,7 @@ describe Braintree::Transaction do
|
|
6416
6546
|
},
|
6417
6547
|
:options => {
|
6418
6548
|
:submit_for_settlement => true
|
6419
|
-
}
|
6549
|
+
},
|
6420
6550
|
)
|
6421
6551
|
|
6422
6552
|
config = Braintree::Configuration.instantiate
|
@@ -6430,7 +6560,7 @@ describe Braintree::Transaction do
|
|
6430
6560
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
6431
6561
|
:options => {
|
6432
6562
|
:submit_for_settlement => true
|
6433
|
-
}
|
6563
|
+
},
|
6434
6564
|
)
|
6435
6565
|
|
6436
6566
|
config = Braintree::Configuration.instantiate
|
@@ -6446,8 +6576,8 @@ describe Braintree::Transaction do
|
|
6446
6576
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6447
6577
|
:expiration_date => "05/2009"
|
6448
6578
|
},
|
6449
|
-
:service_fee_amount =>
|
6450
|
-
:options => {
|
6579
|
+
:service_fee_amount => "1.00",
|
6580
|
+
:options => {:hold_in_escrow => true},
|
6451
6581
|
)
|
6452
6582
|
|
6453
6583
|
config = Braintree::Configuration.instantiate
|
@@ -6461,7 +6591,7 @@ describe Braintree::Transaction do
|
|
6461
6591
|
it "can create a transaction with venmo_sdk_payment_method_code" do
|
6462
6592
|
result = Braintree::Transaction.sale(
|
6463
6593
|
:amount => "10.00",
|
6464
|
-
: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),
|
6465
6595
|
)
|
6466
6596
|
result.success?.should == true
|
6467
6597
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6470,7 +6600,7 @@ describe Braintree::Transaction do
|
|
6470
6600
|
it "errors when an invalid payment method code is passed" do
|
6471
6601
|
result = Braintree::Transaction.sale(
|
6472
6602
|
:amount => "10.00",
|
6473
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
|
6603
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
|
6474
6604
|
)
|
6475
6605
|
result.success?.should == false
|
6476
6606
|
result.message.should include("Invalid VenmoSDK payment method code")
|
@@ -6488,7 +6618,7 @@ describe Braintree::Transaction do
|
|
6488
6618
|
},
|
6489
6619
|
:options => {
|
6490
6620
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
6491
|
-
}
|
6621
|
+
},
|
6492
6622
|
)
|
6493
6623
|
result.success?.should == true
|
6494
6624
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6503,7 +6633,7 @@ describe Braintree::Transaction do
|
|
6503
6633
|
},
|
6504
6634
|
:options => {
|
6505
6635
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
6506
|
-
}
|
6636
|
+
},
|
6507
6637
|
)
|
6508
6638
|
result.success?.should == true
|
6509
6639
|
result.transaction.credit_card_details.venmo_sdk?.should == false
|
@@ -6515,7 +6645,7 @@ describe Braintree::Transaction do
|
|
6515
6645
|
it "can create a transaction for a paypal account" do
|
6516
6646
|
result = Braintree::Transaction.sale(
|
6517
6647
|
:amount => "10.00",
|
6518
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
6648
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6519
6649
|
)
|
6520
6650
|
result.success?.should == true
|
6521
6651
|
result.transaction.paypal_details.payer_email.should == "payer@example.com"
|
@@ -6530,7 +6660,7 @@ describe Braintree::Transaction do
|
|
6530
6660
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6531
6661
|
:options => {
|
6532
6662
|
:store_in_vault => true
|
6533
|
-
}
|
6663
|
+
},
|
6534
6664
|
)
|
6535
6665
|
result.success?.should == true
|
6536
6666
|
result.transaction.paypal_details.token.should_not be_nil
|
@@ -6543,7 +6673,7 @@ describe Braintree::Transaction do
|
|
6543
6673
|
customer = Braintree::Customer.create!
|
6544
6674
|
result = Braintree::PaymentMethod.create(
|
6545
6675
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
6546
|
-
:customer_id => customer.id
|
6676
|
+
:customer_id => customer.id,
|
6547
6677
|
)
|
6548
6678
|
|
6549
6679
|
result.should be_success
|
@@ -6553,7 +6683,7 @@ describe Braintree::Transaction do
|
|
6553
6683
|
result = Braintree::Transaction.sale(
|
6554
6684
|
:amount => "100",
|
6555
6685
|
:customer_id => customer.id,
|
6556
|
-
:payment_method_token => payment_method_token
|
6686
|
+
:payment_method_token => payment_method_token,
|
6557
6687
|
)
|
6558
6688
|
|
6559
6689
|
result.should be_success
|
@@ -6568,7 +6698,7 @@ describe Braintree::Transaction do
|
|
6568
6698
|
nonce = nonce_for_paypal_account(:token => "TOKEN")
|
6569
6699
|
result = Braintree::Transaction.sale(
|
6570
6700
|
:amount => "10.00",
|
6571
|
-
:payment_method_nonce => nonce
|
6701
|
+
:payment_method_nonce => nonce,
|
6572
6702
|
)
|
6573
6703
|
result.should_not be_success
|
6574
6704
|
result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount
|
@@ -6583,7 +6713,7 @@ describe Braintree::Transaction do
|
|
6583
6713
|
:public_key => "oauth_app_partner_user_public_key",
|
6584
6714
|
:private_key => "oauth_app_partner_user_private_key",
|
6585
6715
|
:environment => Braintree::Configuration.environment,
|
6586
|
-
:logger => Logger.new("/dev/null")
|
6716
|
+
:logger => Logger.new("/dev/null"),
|
6587
6717
|
)
|
6588
6718
|
@customer = @partner_merchant_gateway.customer.create(
|
6589
6719
|
:first_name => "Joe",
|
@@ -6592,12 +6722,12 @@ describe Braintree::Transaction do
|
|
6592
6722
|
:email => "joe@example.com",
|
6593
6723
|
:phone => "312.555.1234",
|
6594
6724
|
:fax => "614.555.5678",
|
6595
|
-
:website => "www.example.com"
|
6725
|
+
:website => "www.example.com",
|
6596
6726
|
).customer
|
6597
6727
|
@address = @partner_merchant_gateway.address.create(
|
6598
6728
|
:customer_id => @customer.id,
|
6599
6729
|
:first_name => "Testy",
|
6600
|
-
:last_name => "McTesterson"
|
6730
|
+
:last_name => "McTesterson",
|
6601
6731
|
).address
|
6602
6732
|
@credit_card = @partner_merchant_gateway.credit_card.create(
|
6603
6733
|
:customer_id => @customer.id,
|
@@ -6608,13 +6738,13 @@ describe Braintree::Transaction do
|
|
6608
6738
|
:first_name => "Adam",
|
6609
6739
|
:last_name => "Davis",
|
6610
6740
|
:postal_code => "95131"
|
6611
|
-
}
|
6741
|
+
},
|
6612
6742
|
).credit_card
|
6613
6743
|
|
6614
6744
|
oauth_gateway = Braintree::Gateway.new(
|
6615
6745
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
6616
6746
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
6617
|
-
:logger => Logger.new("/dev/null")
|
6747
|
+
:logger => Logger.new("/dev/null"),
|
6618
6748
|
)
|
6619
6749
|
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
6620
6750
|
:merchant_public_id => "integration_merchant_id",
|
@@ -6623,7 +6753,7 @@ describe Braintree::Transaction do
|
|
6623
6753
|
|
6624
6754
|
@granting_gateway = Braintree::Gateway.new(
|
6625
6755
|
:access_token => access_token,
|
6626
|
-
:logger => Logger.new("/dev/null")
|
6756
|
+
:logger => Logger.new("/dev/null"),
|
6627
6757
|
)
|
6628
6758
|
|
6629
6759
|
end
|
@@ -6633,7 +6763,7 @@ describe Braintree::Transaction do
|
|
6633
6763
|
|
6634
6764
|
result = Braintree::Transaction.sale(
|
6635
6765
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
6636
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6766
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6637
6767
|
)
|
6638
6768
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6639
6769
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6649,7 +6779,7 @@ describe Braintree::Transaction do
|
|
6649
6779
|
|
6650
6780
|
result = Braintree::Transaction.sale(
|
6651
6781
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
6652
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6782
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6653
6783
|
)
|
6654
6784
|
|
6655
6785
|
result.transaction.billing_details.postal_code == "95131"
|
@@ -6661,7 +6791,7 @@ describe Braintree::Transaction do
|
|
6661
6791
|
:shared_customer_id => @customer.id,
|
6662
6792
|
:shared_shipping_address_id => @address.id,
|
6663
6793
|
:shared_billing_address_id => @address.id,
|
6664
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6794
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6665
6795
|
)
|
6666
6796
|
result.success?.should == true
|
6667
6797
|
result.transaction.shipping_details.first_name.should == @address.first_name
|
@@ -6671,7 +6801,7 @@ describe Braintree::Transaction do
|
|
6671
6801
|
it "facilitated details are returned on transaction created via a shared_payment_method_token" do
|
6672
6802
|
result = @granting_gateway.transaction.sale(
|
6673
6803
|
:shared_payment_method_token => @credit_card.token,
|
6674
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6804
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6675
6805
|
)
|
6676
6806
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6677
6807
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6683,12 +6813,12 @@ describe Braintree::Transaction do
|
|
6683
6813
|
|
6684
6814
|
it "facilitated details are returned on transaction created via a shared_payment_method_nonce" do
|
6685
6815
|
shared_nonce = @partner_merchant_gateway.payment_method_nonce.create(
|
6686
|
-
@credit_card.token
|
6816
|
+
@credit_card.token,
|
6687
6817
|
).payment_method_nonce.nonce
|
6688
6818
|
|
6689
6819
|
result = @granting_gateway.transaction.sale(
|
6690
6820
|
:shared_payment_method_nonce => shared_nonce,
|
6691
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
6821
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6692
6822
|
)
|
6693
6823
|
result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
|
6694
6824
|
result.transaction.facilitated_details.merchant_name.should == "14ladders"
|
@@ -6701,7 +6831,7 @@ describe Braintree::Transaction do
|
|
6701
6831
|
|
6702
6832
|
context "paypal here" do
|
6703
6833
|
it "gets the details of an auth/capture transaction" do
|
6704
|
-
result = Braintree::Transaction.find(
|
6834
|
+
result = Braintree::Transaction.find("paypal_here_auth_capture_id")
|
6705
6835
|
result.payment_instrument_type.should eq(Braintree::PaymentInstrumentType::PayPalHere)
|
6706
6836
|
result.paypal_here_details.should_not be_nil
|
6707
6837
|
|
@@ -6718,7 +6848,7 @@ describe Braintree::Transaction do
|
|
6718
6848
|
end
|
6719
6849
|
|
6720
6850
|
it "gets the details of a sale transaction" do
|
6721
|
-
result = Braintree::Transaction.find(
|
6851
|
+
result = Braintree::Transaction.find("paypal_here_sale_id")
|
6722
6852
|
result.paypal_here_details.should_not be_nil
|
6723
6853
|
|
6724
6854
|
details = result.paypal_here_details
|
@@ -6726,7 +6856,7 @@ describe Braintree::Transaction do
|
|
6726
6856
|
end
|
6727
6857
|
|
6728
6858
|
it "gets the details of a refunded sale transaction" do
|
6729
|
-
result = Braintree::Transaction.find(
|
6859
|
+
result = Braintree::Transaction.find("paypal_here_refund_id")
|
6730
6860
|
result.paypal_here_details.should_not be_nil
|
6731
6861
|
|
6732
6862
|
details = result.paypal_here_details
|
@@ -6751,7 +6881,7 @@ describe Braintree::Transaction do
|
|
6751
6881
|
customer = Braintree::Customer.create!
|
6752
6882
|
result = Braintree::PaymentMethod.create(
|
6753
6883
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
6754
|
-
:customer_id => customer.id
|
6884
|
+
:customer_id => customer.id,
|
6755
6885
|
)
|
6756
6886
|
payment_method_token = result.payment_method.token
|
6757
6887
|
|
@@ -6766,4 +6896,230 @@ describe Braintree::Transaction do
|
|
6766
6896
|
transaction.processed_with_network_token?.should == false
|
6767
6897
|
end
|
6768
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 "Adjust Authorization" do
|
6988
|
+
let(:first_data_master_transaction_params) do
|
6989
|
+
{
|
6990
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
6991
|
+
:amount => "75.50",
|
6992
|
+
:credit_card => {
|
6993
|
+
:number => "5105105105105100",
|
6994
|
+
:expiration_date => "05/2012"
|
6995
|
+
}
|
6996
|
+
}
|
6997
|
+
end
|
6998
|
+
let(:first_data_visa_transaction_params) do
|
6999
|
+
{
|
7000
|
+
:merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
|
7001
|
+
:amount => "75.50",
|
7002
|
+
:credit_card => {
|
7003
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7004
|
+
:expiration_date => "06/2009"
|
7005
|
+
}
|
7006
|
+
}
|
7007
|
+
end
|
7008
|
+
context "successful authorization" do
|
7009
|
+
it "returns success response" do
|
7010
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7011
|
+
expect(initial_transaction.success?).to eq(true)
|
7012
|
+
|
7013
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7014
|
+
initial_transaction.transaction.id, "85.50"
|
7015
|
+
)
|
7016
|
+
|
7017
|
+
expect(adjustment_transaction.success?).to eq(true)
|
7018
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("85.50"))
|
7019
|
+
end
|
7020
|
+
end
|
7021
|
+
|
7022
|
+
context "unsuccessful authorization" do
|
7023
|
+
it "returns failure, when processor does not support multi auth adjustment" do
|
7024
|
+
initial_transaction = Braintree::Transaction.sale(
|
7025
|
+
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
7026
|
+
:amount => "75.50",
|
7027
|
+
:credit_card => {
|
7028
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
7029
|
+
:expiration_date => "06/2009"
|
7030
|
+
},
|
7031
|
+
)
|
7032
|
+
expect(initial_transaction.success?).to eq(true)
|
7033
|
+
|
7034
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7035
|
+
initial_transaction.transaction.id, "85.50"
|
7036
|
+
)
|
7037
|
+
|
7038
|
+
|
7039
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7040
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7041
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportAuthAdjustment)
|
7042
|
+
end
|
7043
|
+
|
7044
|
+
it "returns failure response, when adjusted amount submitted is zero" do
|
7045
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7046
|
+
expect(initial_transaction.success?).to eq(true)
|
7047
|
+
|
7048
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7049
|
+
initial_transaction.transaction.id, "0.0"
|
7050
|
+
)
|
7051
|
+
|
7052
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7053
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7054
|
+
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AdjustmentAmountMustBeGreaterThanZero)
|
7055
|
+
end
|
7056
|
+
|
7057
|
+
it "returns failure response, when adjusted amount submitted same as authorized amount" do
|
7058
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
|
7059
|
+
expect(initial_transaction.success?).to eq(true)
|
7060
|
+
|
7061
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7062
|
+
initial_transaction.transaction.id, "75.50"
|
7063
|
+
)
|
7064
|
+
|
7065
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7066
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7067
|
+
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
|
7068
|
+
end
|
7069
|
+
|
7070
|
+
it "returns failure, when transaction status is not authorized" do
|
7071
|
+
additional_params = {:options => {:submit_for_settlement => true}}
|
7072
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7073
|
+
expect(initial_transaction.success?).to eq(true)
|
7074
|
+
|
7075
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7076
|
+
initial_transaction.transaction.id, "85.50"
|
7077
|
+
)
|
7078
|
+
|
7079
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7080
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7081
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
|
7082
|
+
end
|
7083
|
+
|
7084
|
+
it "returns failure, when transaction authorization type final or undefined" do
|
7085
|
+
additional_params = {:transaction_source => "recurring_first"}
|
7086
|
+
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7087
|
+
expect(initial_transaction.success?).to eq(true)
|
7088
|
+
|
7089
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7090
|
+
initial_transaction.transaction.id, "85.50"
|
7091
|
+
)
|
7092
|
+
|
7093
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7094
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7095
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionIsNotEligibleForAdjustment)
|
7096
|
+
end
|
7097
|
+
|
7098
|
+
it "returns failure, when processor does not support incremental auth" do
|
7099
|
+
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7100
|
+
expect(initial_transaction.success?).to eq(true)
|
7101
|
+
|
7102
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7103
|
+
initial_transaction.transaction.id, "85.50"
|
7104
|
+
)
|
7105
|
+
|
7106
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7107
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7108
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportIncrementalAuth)
|
7109
|
+
end
|
7110
|
+
|
7111
|
+
it "returns failure, when processor does not support auth reversal" do
|
7112
|
+
initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
|
7113
|
+
expect(initial_transaction.success?).to eq(true)
|
7114
|
+
|
7115
|
+
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7116
|
+
initial_transaction.transaction.id, "65.50"
|
7117
|
+
)
|
7118
|
+
|
7119
|
+
expect(adjustment_transaction.success?).to eq(false)
|
7120
|
+
expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
|
7121
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialAuthReversal)
|
7122
|
+
end
|
7123
|
+
end
|
7124
|
+
end
|
6769
7125
|
end
|