braintree 2.36.0 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/braintree.rb +1 -0
- data/lib/braintree/credit_card.rb +7 -1
- data/lib/braintree/credit_card_gateway.rb +1 -1
- data/lib/braintree/credit_card_verification.rb +2 -1
- data/lib/braintree/customer.rb +3 -2
- data/lib/braintree/error_codes.rb +19 -0
- data/lib/braintree/payment_method_gateway.rb +2 -0
- data/lib/braintree/risk_data.rb +19 -0
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/transaction.rb +3 -0
- data/lib/braintree/transaction_gateway.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +1 -1
- data/spec/httpsd.pid +1 -1
- data/spec/integration/braintree/credit_card_spec.rb +33 -27
- data/spec/integration/braintree/customer_spec.rb +28 -0
- data/spec/integration/braintree/payment_method_spec.rb +60 -0
- data/spec/integration/braintree/transaction_spec.rb +101 -154
- data/spec/integration/spec_helper.rb +1 -1
- data/spec/script/httpsd.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +18 -2
- data/spec/unit/braintree/credit_card_verification_spec.rb +13 -0
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/risk_data_spec.rb +21 -0
- data/spec/unit/braintree/transaction_spec.rb +8 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +40 -40
- metadata +143 -145
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c48ff6229db7ba353e35139264ee163912aad603
|
4
|
+
data.tar.gz: 923b9b3a830e9ea040579593e4f21e27b3161efa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0e8171010de2bff30836124bfcf8421afa7e3093d5f19e1550a7cb45497d83be5e5f88483cf9cb6611c2aaa69d53645edfd6a1204c331c050b3a33232fdc3d0
|
7
|
+
data.tar.gz: 6da4afeea421900cc0c429e9410fa14cd164e60711bd3b81bfad62b9bc9e6f7498d19de7a74a012404031f9ce3c15a0e57e63c16a66c2f6e3fa37ba9c548246d
|
data/lib/braintree.rb
CHANGED
@@ -62,6 +62,7 @@ require "braintree/paypal_account"
|
|
62
62
|
require "braintree/paypal_account_gateway"
|
63
63
|
require "braintree/plan"
|
64
64
|
require "braintree/plan_gateway"
|
65
|
+
require "braintree/risk_data"
|
65
66
|
require "braintree/settlement_batch_summary"
|
66
67
|
require "braintree/settlement_batch_summary_gateway"
|
67
68
|
require "braintree/resource_collection"
|
@@ -38,7 +38,7 @@ module Braintree
|
|
38
38
|
attr_reader :billing_address, :bin, :card_type, :cardholder_name, :commercial, :country_of_issuance,
|
39
39
|
:created_at, :customer_id, :debit, :durbin_regulated, :expiration_month, :expiration_year, :healthcare,
|
40
40
|
:issuing_bank, :last_4, :payroll, :prepaid, :subscriptions, :token, :unique_number_identifier, :updated_at,
|
41
|
-
:image_url
|
41
|
+
:image_url, :verification
|
42
42
|
|
43
43
|
# See http://www.braintreepayments.com/docs/ruby/credit_cards/create
|
44
44
|
def self.create(attributes)
|
@@ -139,6 +139,12 @@ module Braintree
|
|
139
139
|
set_instance_variables_from_hash(attributes)
|
140
140
|
@billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
|
141
141
|
@subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
|
142
|
+
@verification = _most_recent_verification(attributes)
|
143
|
+
end
|
144
|
+
|
145
|
+
def _most_recent_verification(attributes)
|
146
|
+
verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
|
147
|
+
CreditCardVerification._new(verification) if verification
|
142
148
|
end
|
143
149
|
|
144
150
|
# Deprecated. Use Braintree::CreditCard.credit
|
@@ -84,7 +84,7 @@ module Braintree
|
|
84
84
|
|
85
85
|
def self._signature(type) # :nodoc:
|
86
86
|
billing_address_params = AddressGateway._shared_signature
|
87
|
-
options = [:make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session]
|
87
|
+
options = [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session]
|
88
88
|
signature = [
|
89
89
|
:billing_address_id, :cardholder_name, :cvv, :device_session_id, :expiration_date,
|
90
90
|
:expiration_month, :expiration_year, :number, :token, :venmo_sdk_payment_method_code,
|
@@ -12,10 +12,11 @@ module Braintree
|
|
12
12
|
|
13
13
|
attr_reader :avs_error_response_code, :avs_postal_code_response_code, :avs_street_address_response_code,
|
14
14
|
:cvv_response_code, :merchant_account_id, :processor_response_code, :processor_response_text, :status,
|
15
|
-
:id, :gateway_rejection_reason, :credit_card, :billing, :created_at
|
15
|
+
:id, :gateway_rejection_reason, :credit_card, :billing, :created_at, :risk_data
|
16
16
|
|
17
17
|
def initialize(attributes) # :nodoc:
|
18
18
|
set_instance_variables_from_hash(attributes)
|
19
|
+
@risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data]
|
19
20
|
end
|
20
21
|
|
21
22
|
def inspect # :nodoc:
|
data/lib/braintree/customer.rb
CHANGED
@@ -4,7 +4,7 @@ module Braintree
|
|
4
4
|
include BaseModule
|
5
5
|
|
6
6
|
attr_reader :addresses, :company, :created_at, :credit_cards, :email, :fax, :first_name, :id, :last_name,
|
7
|
-
:phone, :updated_at, :website, :custom_fields, :paypal_accounts
|
7
|
+
:phone, :updated_at, :website, :custom_fields, :paypal_accounts, :apple_pay_cards
|
8
8
|
|
9
9
|
# See http://www.braintreepayments.com/docs/ruby/customers/search
|
10
10
|
def self.all
|
@@ -108,6 +108,7 @@ module Braintree
|
|
108
108
|
set_instance_variables_from_hash(attributes)
|
109
109
|
@credit_cards = (@credit_cards || []).map { |pm| CreditCard._new gateway, pm }
|
110
110
|
@paypal_accounts = (@paypal_accounts || []).map { |pm| PayPalAccount._new gateway, pm }
|
111
|
+
@apple_pay_cards = (@apple_pay_cards || []).map { |pm| ApplePayCard._new gateway, pm }
|
111
112
|
@addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
|
112
113
|
@custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
|
113
114
|
end
|
@@ -142,7 +143,7 @@ module Braintree
|
|
142
143
|
|
143
144
|
# Returns the customer's payment methods
|
144
145
|
def payment_methods
|
145
|
-
@credit_cards.dup + @paypal_accounts.dup
|
146
|
+
@credit_cards.dup + @paypal_accounts.dup + @apple_pay_cards.dup
|
146
147
|
end
|
147
148
|
|
148
149
|
def inspect # :nodoc:
|
@@ -293,6 +293,25 @@ module Braintree
|
|
293
293
|
SubmitForSettlementIsRequiredForCloning = "91544"
|
294
294
|
VaultIsDisabled = "91525"
|
295
295
|
end
|
296
|
+
|
297
|
+
module Industry
|
298
|
+
module Lodging
|
299
|
+
EmptyData = "93402"
|
300
|
+
FolioNumberIsInvalid = "93403"
|
301
|
+
CheckInDateIsInvalid = "93404"
|
302
|
+
CheckOutDateIsInvalid = "93405"
|
303
|
+
CheckOutDateMustFollowCheckInDate = "93406"
|
304
|
+
end
|
305
|
+
|
306
|
+
module TravelCruise
|
307
|
+
EmptyData = "93408"
|
308
|
+
UnknownDataField = "93409"
|
309
|
+
TravelPackageIsInvalid = "93410"
|
310
|
+
DepartureDateIsInvalid = "93411"
|
311
|
+
LodgingCheckInDateIsInvalid = "93412"
|
312
|
+
LodgingCheckOutDateIsInvalid = "93413"
|
313
|
+
end
|
314
|
+
end
|
296
315
|
end
|
297
316
|
|
298
317
|
module MerchantAccount
|
@@ -42,6 +42,8 @@ module Braintree
|
|
42
42
|
PayPalAccount._new(@gateway, response[:paypal_account])
|
43
43
|
elsif response.has_key?(:sepa_bank_account)
|
44
44
|
SEPABankAccount._new(@gateway, response[:sepa_bank_account])
|
45
|
+
elsif response.has_key?(:apple_pay_card)
|
46
|
+
ApplePayCard._new(@gateway, response[:apple_pay_card])
|
45
47
|
else
|
46
48
|
UnknownPaymentMethod._new(@gateway, response)
|
47
49
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Braintree
|
2
|
+
class RiskData # :nodoc:
|
3
|
+
include BaseModule
|
4
|
+
|
5
|
+
attr_reader :id, :decision
|
6
|
+
|
7
|
+
def initialize(attributes)
|
8
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
attr_order = [:id, :decision]
|
13
|
+
formatted_attrs = attr_order.map do |attr|
|
14
|
+
"#{attr}: #{send(attr).inspect}"
|
15
|
+
end
|
16
|
+
"#<RiskData #{formatted_attrs.join(", ")}>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/braintree/test/nonce.rb
CHANGED
@@ -55,6 +55,7 @@ module Braintree
|
|
55
55
|
|
56
56
|
module IndustryType
|
57
57
|
Lodging = "lodging"
|
58
|
+
TravelAndCruise = "travel_cruise"
|
58
59
|
|
59
60
|
All = constants.map { |c| const_get(c) }
|
60
61
|
end
|
@@ -111,6 +112,7 @@ module Braintree
|
|
111
112
|
attr_reader :updated_at
|
112
113
|
attr_reader :add_ons, :discounts
|
113
114
|
attr_reader :payment_instrument_type
|
115
|
+
attr_reader :risk_data
|
114
116
|
|
115
117
|
# See http://www.braintreepayments.com/docs/ruby/transactions/create
|
116
118
|
def self.create(attributes)
|
@@ -249,6 +251,7 @@ module Braintree
|
|
249
251
|
add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons
|
250
252
|
discounts.map! { |attrs| Discount._new(attrs) } if discounts
|
251
253
|
@payment_instrument_type = attributes[:payment_instrument_type]
|
254
|
+
@risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data]
|
252
255
|
end
|
253
256
|
|
254
257
|
# True if <tt>other</tt> is a Braintree::Transaction with the same id.
|
@@ -131,7 +131,7 @@ module Braintree
|
|
131
131
|
{:custom_fields => :_any_key_},
|
132
132
|
{:descriptor => [:name, :phone, :url]},
|
133
133
|
{:paypal_account => [:email, :token, :paypal_data, :payee_email]},
|
134
|
-
{:industry => [:industry_type, {:data => [:folio_number, :check_in_date, :check_out_date]}]}
|
134
|
+
{:industry => [:industry_type, {:data => [:folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate]}]}
|
135
135
|
]
|
136
136
|
end
|
137
137
|
|
data/lib/braintree/version.rb
CHANGED
@@ -9,7 +9,7 @@ module Braintree
|
|
9
9
|
payload = Base64.encode64(_sample_xml(kind, id))
|
10
10
|
signature_string = "#{@config.public_key}|#{Braintree::Digest.hexdigest(@config.private_key, payload)}"
|
11
11
|
|
12
|
-
return signature_string, payload
|
12
|
+
return {:bt_signature => signature_string, :bt_payload => payload}
|
13
13
|
end
|
14
14
|
|
15
15
|
def _sample_xml(kind, data)
|
data/spec/httpsd.pid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
22683
|
@@ -119,6 +119,21 @@ describe Braintree::CreditCard do
|
|
119
119
|
result.credit_card_verification.avs_street_address_response_code.should == "I"
|
120
120
|
end
|
121
121
|
|
122
|
+
it "returns risk data on verification on credit_card create" do
|
123
|
+
customer = Braintree::Customer.create!
|
124
|
+
credit_card = Braintree::CreditCard.create!(
|
125
|
+
:cardholder_name => "Original Holder",
|
126
|
+
:customer_id => customer.id,
|
127
|
+
:cvv => "123",
|
128
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
129
|
+
:expiration_date => "05/2020",
|
130
|
+
:options => {:verify_card => true}
|
131
|
+
)
|
132
|
+
verification = credit_card.verification
|
133
|
+
verification.risk_data.should respond_to(:id)
|
134
|
+
verification.risk_data.should respond_to(:decision)
|
135
|
+
end
|
136
|
+
|
122
137
|
it "exposes the gateway rejection reason on verification" do
|
123
138
|
old_merchant = Braintree::Configuration.merchant_id
|
124
139
|
old_public_key = Braintree::Configuration.public_key
|
@@ -146,6 +161,24 @@ describe Braintree::CreditCard do
|
|
146
161
|
end
|
147
162
|
end
|
148
163
|
|
164
|
+
it "verifies the credit card if options[verify_card]=true" do
|
165
|
+
customer = Braintree::Customer.create!
|
166
|
+
result = Braintree::CreditCard.create(
|
167
|
+
:customer_id => customer.id,
|
168
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
169
|
+
:expiration_date => "05/2009",
|
170
|
+
:options => {:verify_card => true, :verification_amount => "1.01"}
|
171
|
+
)
|
172
|
+
result.success?.should == false
|
173
|
+
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
174
|
+
result.credit_card_verification.processor_response_code.should == "2000"
|
175
|
+
result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
176
|
+
result.credit_card_verification.cvv_response_code.should == "I"
|
177
|
+
result.credit_card_verification.avs_error_response_code.should == nil
|
178
|
+
result.credit_card_verification.avs_postal_code_response_code.should == "I"
|
179
|
+
result.credit_card_verification.avs_street_address_response_code.should == "I"
|
180
|
+
end
|
181
|
+
|
149
182
|
it "allows user to specify merchant account for verification" do
|
150
183
|
customer = Braintree::Customer.create!
|
151
184
|
result = Braintree::CreditCard.create(
|
@@ -1193,33 +1226,6 @@ describe Braintree::CreditCard do
|
|
1193
1226
|
end.to raise_error(Braintree::NotFoundError)
|
1194
1227
|
end
|
1195
1228
|
|
1196
|
-
it "does not find the payment method for a locked nonce" do
|
1197
|
-
raw_client_token = Braintree::ClientToken.generate
|
1198
|
-
client_token = decode_client_token(raw_client_token)
|
1199
|
-
client = ClientApiHttp.new(Braintree::Configuration.instantiate,
|
1200
|
-
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
1201
|
-
:shared_customer_identifier => "fake_identifier",
|
1202
|
-
:shared_customer_identifier_type => "testing"
|
1203
|
-
)
|
1204
|
-
|
1205
|
-
client.add_payment_method(
|
1206
|
-
:credit_card => {
|
1207
|
-
:number => "4111111111111111",
|
1208
|
-
:expiration_month => "11",
|
1209
|
-
:expiration_year => "2099",
|
1210
|
-
},
|
1211
|
-
:share => true
|
1212
|
-
)
|
1213
|
-
|
1214
|
-
response = client.get_payment_methods
|
1215
|
-
body = JSON.parse(response.body)
|
1216
|
-
nonce = body["paymentMethods"].first["nonce"]
|
1217
|
-
|
1218
|
-
expect do
|
1219
|
-
Braintree::CreditCard.from_nonce(nonce)
|
1220
|
-
end.to raise_error(Braintree::NotFoundError, /locked/)
|
1221
|
-
end
|
1222
|
-
|
1223
1229
|
it "does not find the payment method for a consumednonce" do
|
1224
1230
|
customer = Braintree::Customer.create!
|
1225
1231
|
nonce = nonce_for_new_payment_method(
|
@@ -403,6 +403,20 @@ describe Braintree::Customer do
|
|
403
403
|
result.customer.credit_cards.first.last_4.should == "1111"
|
404
404
|
end
|
405
405
|
end
|
406
|
+
|
407
|
+
it "can create a customer with an apple pay payment method" do
|
408
|
+
result = Braintree::Customer.create(:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa)
|
409
|
+
|
410
|
+
result.success?.should == true
|
411
|
+
result.customer.payment_methods.should_not be_empty
|
412
|
+
result.customer.payment_methods.first.token.should_not be_nil
|
413
|
+
end
|
414
|
+
|
415
|
+
it "can create a customer with an unknown payment method" do
|
416
|
+
result = Braintree::Customer.create(:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable)
|
417
|
+
|
418
|
+
result.success?.should == true
|
419
|
+
end
|
406
420
|
end
|
407
421
|
|
408
422
|
describe "self.create!" do
|
@@ -730,6 +744,20 @@ describe Braintree::Customer do
|
|
730
744
|
found_customer.credit_cards.first.subscriptions.first.price.should == BigDecimal.new("1.00")
|
731
745
|
end
|
732
746
|
|
747
|
+
it "returns associated ApplePayCards" do
|
748
|
+
result = Braintree::Customer.create(
|
749
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx
|
750
|
+
)
|
751
|
+
result.success?.should == true
|
752
|
+
|
753
|
+
found_customer = Braintree::Customer.find(result.customer.id)
|
754
|
+
found_customer.apple_pay_cards.should_not be_nil
|
755
|
+
apple_pay_card = found_customer.apple_pay_cards.first
|
756
|
+
apple_pay_card.should be_a Braintree::ApplePayCard
|
757
|
+
apple_pay_card.token.should_not be_nil
|
758
|
+
apple_pay_card.expiration_year.should_not be_nil
|
759
|
+
end
|
760
|
+
|
733
761
|
it "works for a blank customer" do
|
734
762
|
created_customer = Braintree::Customer.create!
|
735
763
|
found_customer = Braintree::Customer.find(created_customer.id)
|
@@ -487,6 +487,24 @@ describe Braintree::PaymentMethod do
|
|
487
487
|
result.payment_method.image_url.should_not be_nil
|
488
488
|
end
|
489
489
|
end
|
490
|
+
|
491
|
+
context "Unknown payment methods" do
|
492
|
+
it "creates an unknown payment method from a nonce" do
|
493
|
+
customer = Braintree::Customer.create.customer
|
494
|
+
token = SecureRandom.hex(16)
|
495
|
+
result = Braintree::PaymentMethod.create(
|
496
|
+
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
497
|
+
:customer_id => customer.id,
|
498
|
+
:token => token
|
499
|
+
)
|
500
|
+
|
501
|
+
result.should be_success
|
502
|
+
payment_method = result.payment_method
|
503
|
+
payment_method.should_not be_nil
|
504
|
+
payment_method.token.should == token
|
505
|
+
payment_method.should be_a Braintree::UnknownPaymentMethod
|
506
|
+
end
|
507
|
+
end
|
490
508
|
end
|
491
509
|
|
492
510
|
describe "self.find" do
|
@@ -550,6 +568,48 @@ describe Braintree::PaymentMethod do
|
|
550
568
|
end
|
551
569
|
end
|
552
570
|
|
571
|
+
context "apple pay cards" do
|
572
|
+
it "finds the payment method with the given token" do
|
573
|
+
customer = Braintree::Customer.create!
|
574
|
+
payment_method_token = "PAYMENT_METHOD_TOKEN_#{rand(36**3).to_s(36)}"
|
575
|
+
result = Braintree::PaymentMethod.create(
|
576
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
577
|
+
:customer_id => customer.id,
|
578
|
+
:token => payment_method_token
|
579
|
+
)
|
580
|
+
result.should be_success
|
581
|
+
|
582
|
+
apple_pay_card = Braintree::PaymentMethod.find(payment_method_token)
|
583
|
+
apple_pay_card.should be_a(Braintree::ApplePayCard)
|
584
|
+
apple_pay_card.should_not be_nil
|
585
|
+
apple_pay_card.token.should == payment_method_token
|
586
|
+
apple_pay_card.card_type.should == Braintree::ApplePayCard::CardType::AmEx
|
587
|
+
apple_pay_card.default.should == true
|
588
|
+
apple_pay_card.image_url.should =~ /apple_pay/
|
589
|
+
apple_pay_card.expiration_month.to_i.should > 0
|
590
|
+
apple_pay_card.expiration_year.to_i.should > 0
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
context "unknown payment methods" do
|
595
|
+
it "finds the payment method with the given token" do
|
596
|
+
customer = Braintree::Customer.create!
|
597
|
+
payment_method_token = "FUTURE_PAYMENT_#{rand(36**3).to_s(36)}"
|
598
|
+
result = Braintree::PaymentMethod.create(
|
599
|
+
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
600
|
+
:customer_id => customer.id,
|
601
|
+
:token => payment_method_token
|
602
|
+
)
|
603
|
+
result.should be_success
|
604
|
+
|
605
|
+
payment_method = Braintree::PaymentMethod.find(payment_method_token)
|
606
|
+
payment_method.should_not be_nil
|
607
|
+
payment_method.token.should == payment_method_token
|
608
|
+
payment_method.image_url.should_not be_nil
|
609
|
+
payment_method.should be_a Braintree::UnknownPaymentMethod
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
553
613
|
it "raises a NotFoundError exception if payment method cannot be found" do
|
554
614
|
expect do
|
555
615
|
Braintree::PaymentMethod.find("invalid-token")
|
@@ -122,190 +122,126 @@ describe Braintree::Transaction do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
describe "self.create" do
|
125
|
-
describe "
|
126
|
-
it "
|
127
|
-
result = Braintree::Transaction.create(
|
128
|
-
:type => "sale",
|
129
|
-
:amount => 1_00,
|
130
|
-
:credit_card => {
|
131
|
-
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
132
|
-
:expiration_date => "05/2009"
|
133
|
-
}
|
134
|
-
)
|
135
|
-
result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
136
|
-
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::CreditCard
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "industry data" do
|
141
|
-
it "accepts valid industry data" do
|
125
|
+
describe "risk data" do
|
126
|
+
it "returns decision and id" do
|
142
127
|
result = Braintree::Transaction.create(
|
143
128
|
:type => "sale",
|
144
129
|
:amount => 1_00,
|
145
130
|
:credit_card => {
|
146
131
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
147
132
|
:expiration_date => "05/2009"
|
148
|
-
},
|
149
|
-
:industry => {
|
150
|
-
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
151
|
-
:data => {
|
152
|
-
:folio_number => "ABCDEFG",
|
153
|
-
:check_in_date => "2014-06-01",
|
154
|
-
:check_out_date => "2014-06-30"
|
155
|
-
}
|
156
|
-
}
|
157
|
-
)
|
158
|
-
result.success?.should be_true
|
159
|
-
end
|
160
|
-
|
161
|
-
it "returns errors if validations on industry data fails" do
|
162
|
-
result = Braintree::Transaction.create(
|
163
|
-
:type => "sale",
|
164
|
-
:amount => 1_00,
|
165
|
-
:credit_card => {
|
166
|
-
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
167
|
-
:expiration_date => "05/2009"
|
168
|
-
},
|
169
|
-
:industry => {
|
170
|
-
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
171
|
-
:data => {
|
172
|
-
:folio_number => "foo bar",
|
173
|
-
:check_in_date => "2014-06-30",
|
174
|
-
:check_out_date => "2014-06-01"
|
175
|
-
}
|
176
133
|
}
|
177
134
|
)
|
178
|
-
result.
|
179
|
-
result.
|
135
|
+
result.transaction.risk_data.should be_a(Braintree::RiskData)
|
136
|
+
result.transaction.risk_data.should respond_to(:id)
|
137
|
+
result.transaction.risk_data.should respond_to(:decision)
|
180
138
|
end
|
181
139
|
end
|
182
140
|
|
183
|
-
describe "
|
184
|
-
it "
|
185
|
-
result = Braintree::Transaction.create(
|
186
|
-
:type => "sale",
|
187
|
-
:amount => 1_00,
|
188
|
-
:credit_card => {
|
189
|
-
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
190
|
-
:expiration_date => "05/2009"
|
191
|
-
},
|
192
|
-
:industry => {
|
193
|
-
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
194
|
-
:data => {
|
195
|
-
:folio_number => "ABCDEFG",
|
196
|
-
:check_in_date => "2014-06-01",
|
197
|
-
:check_out_date => "2014-06-30"
|
198
|
-
}
|
199
|
-
}
|
200
|
-
)
|
201
|
-
result.success?.should be_true
|
202
|
-
end
|
203
|
-
|
204
|
-
it "returns errors if validations on industry data fails" do
|
141
|
+
describe "card type indicators" do
|
142
|
+
it "sets the prepaid field if the card is prepaid" do
|
205
143
|
result = Braintree::Transaction.create(
|
206
144
|
:type => "sale",
|
207
145
|
:amount => 1_00,
|
208
146
|
:credit_card => {
|
209
147
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
210
148
|
:expiration_date => "05/2009"
|
211
|
-
},
|
212
|
-
:industry => {
|
213
|
-
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
214
|
-
:data => {
|
215
|
-
:folio_number => "foo bar",
|
216
|
-
:check_in_date => "2014-06-30",
|
217
|
-
:check_out_date => "2014-06-01"
|
218
|
-
}
|
219
149
|
}
|
220
150
|
)
|
221
|
-
result.
|
222
|
-
result.
|
151
|
+
result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
152
|
+
result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::CreditCard
|
223
153
|
end
|
224
154
|
end
|
225
155
|
|
226
156
|
describe "industry data" do
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
:
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
:
|
237
|
-
|
238
|
-
:
|
239
|
-
|
240
|
-
|
157
|
+
context "for lodging" do
|
158
|
+
it "accepts valid industry data" do
|
159
|
+
result = Braintree::Transaction.create(
|
160
|
+
:type => "sale",
|
161
|
+
:amount => 1_00,
|
162
|
+
:credit_card => {
|
163
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
164
|
+
:expiration_date => "05/2009"
|
165
|
+
},
|
166
|
+
:industry => {
|
167
|
+
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
168
|
+
:data => {
|
169
|
+
:folio_number => "ABCDEFG",
|
170
|
+
:check_in_date => "2014-06-01",
|
171
|
+
:check_out_date => "2014-06-30",
|
172
|
+
:room_rate => "239.00",
|
173
|
+
}
|
241
174
|
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
end
|
175
|
+
)
|
176
|
+
result.success?.should be_true
|
177
|
+
end
|
246
178
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
179
|
+
it "returns errors if validations on industry lodging data fails" do
|
180
|
+
result = Braintree::Transaction.create(
|
181
|
+
:type => "sale",
|
182
|
+
:amount => 1_00,
|
183
|
+
:credit_card => {
|
184
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
185
|
+
:expiration_date => "05/2009"
|
186
|
+
},
|
187
|
+
:industry => {
|
188
|
+
:industry_type => Braintree::Transaction::IndustryType::Lodging,
|
189
|
+
:data => {
|
190
|
+
:folio_number => "foo bar",
|
191
|
+
:check_in_date => "2014-06-30",
|
192
|
+
:check_out_date => "2014-06-01",
|
193
|
+
:room_rate => "asdfasdf",
|
194
|
+
}
|
261
195
|
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
196
|
+
)
|
197
|
+
result.success?.should be_false
|
198
|
+
invalid_folio = Braintree::ErrorCodes::Transaction::Industry::Lodging::FolioNumberIsInvalid
|
199
|
+
check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate
|
200
|
+
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [invalid_folio, check_out_date_must_follow_check_in_date]
|
201
|
+
end
|
266
202
|
end
|
267
|
-
end
|
268
203
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
204
|
+
context "for travel cruise" do
|
205
|
+
it "accepts valid industry data" do
|
206
|
+
result = Braintree::Transaction.create(
|
207
|
+
:type => "sale",
|
208
|
+
:amount => 1_00,
|
209
|
+
:credit_card => {
|
210
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
211
|
+
:expiration_date => "05/2009"
|
212
|
+
},
|
213
|
+
:industry => {
|
214
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndCruise,
|
215
|
+
:data => {
|
216
|
+
:travel_package => "flight",
|
217
|
+
:departure_date => "2014-07-01",
|
218
|
+
:lodging_check_in_date => "2014-07-07",
|
219
|
+
:lodging_check_out_date => "2014-07-07",
|
220
|
+
:lodging_name => "Royal Caribbean",
|
221
|
+
}
|
284
222
|
}
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
end
|
223
|
+
)
|
224
|
+
result.success?.should be_true
|
225
|
+
end
|
289
226
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
:check_out_date => "2014-06-01"
|
227
|
+
it "returns errors if validations on industry data fails" do
|
228
|
+
result = Braintree::Transaction.create(
|
229
|
+
:type => "sale",
|
230
|
+
:amount => 1_00,
|
231
|
+
:credit_card => {
|
232
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
233
|
+
:expiration_date => "05/2009"
|
234
|
+
},
|
235
|
+
:industry => {
|
236
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndCruise,
|
237
|
+
:data => {
|
238
|
+
:lodging_name => "Royal Caribbean"
|
239
|
+
}
|
304
240
|
}
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
241
|
+
)
|
242
|
+
result.success?.should be_false
|
243
|
+
result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelCruise::TravelPackageIsInvalid]
|
244
|
+
end
|
309
245
|
end
|
310
246
|
end
|
311
247
|
|
@@ -1321,7 +1257,7 @@ describe Braintree::Transaction do
|
|
1321
1257
|
result = Braintree::Transaction.create(
|
1322
1258
|
:type => "sale",
|
1323
1259
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1324
|
-
:payment_method_nonce =>
|
1260
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa
|
1325
1261
|
)
|
1326
1262
|
result.success?.should == true
|
1327
1263
|
result.transaction.should_not be_nil
|
@@ -1333,6 +1269,17 @@ describe Braintree::Transaction do
|
|
1333
1269
|
apple_pay_details.cardholder_name.should_not be_nil
|
1334
1270
|
end
|
1335
1271
|
|
1272
|
+
it "can create a transaction with an unknown nonce" do
|
1273
|
+
customer = Braintree::Customer.create!
|
1274
|
+
result = Braintree::Transaction.create(
|
1275
|
+
:type => "sale",
|
1276
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1277
|
+
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable
|
1278
|
+
)
|
1279
|
+
result.success?.should == true
|
1280
|
+
result.transaction.should_not be_nil
|
1281
|
+
end
|
1282
|
+
|
1336
1283
|
it "can create a transaction with a payee email" do
|
1337
1284
|
customer = Braintree::Customer.create!
|
1338
1285
|
nonce = nonce_for_new_payment_method(
|