braintree 4.17.0 → 4.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/advanced_search.rb +1 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/http.rb +2 -4
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction.rb +10 -0
- data/lib/braintree/transaction_gateway.rb +21 -3
- data/lib/braintree/transaction_line_item.rb +11 -8
- data/lib/braintree/util.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +4 -3
- data/lib/braintree/webhook_testing_gateway.rb +78 -6
- data/lib/braintree/xml/parser.rb +2 -2
- data/lib/braintree.rb +1 -0
- data/spec/integration/braintree/address_spec.rb +3 -3
- data/spec/integration/braintree/advanced_search_spec.rb +3 -3
- data/spec/integration/braintree/client_api/client_token_spec.rb +0 -2
- data/spec/integration/braintree/client_api/spec_helper.rb +1 -1
- data/spec/integration/braintree/credit_card_spec.rb +11 -15
- data/spec/integration/braintree/credit_card_verification_spec.rb +2 -2
- data/spec/integration/braintree/customer_spec.rb +12 -12
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/dispute_spec.rb +1 -1
- data/spec/integration/braintree/document_upload_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +0 -2
- data/spec/integration/braintree/oauth_spec.rb +1 -1
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_spec.rb +12 -14
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +3 -3
- data/spec/integration/braintree/paypal_account_spec.rb +6 -6
- data/spec/integration/braintree/plan_spec.rb +0 -1
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +0 -2
- data/spec/integration/braintree/subscription_spec.rb +5 -6
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
- data/spec/integration/braintree/transaction_search_spec.rb +3 -7
- data/spec/integration/braintree/transaction_spec.rb +117 -49
- data/spec/unit/braintree/client_token_spec.rb +1 -1
- data/spec/unit/braintree/digest_spec.rb +0 -1
- data/spec/unit/braintree/error_result_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- data/spec/unit/braintree/paypal_account_spec.rb +1 -1
- data/spec/unit/braintree/transaction_gateway_spec.rb +3 -3
- data/spec/unit/braintree/transaction_spec.rb +2 -2
- data/spec/unit/braintree/webhook_notification_spec.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43df747b2db22253268db6e5f01b79ea162b6c0911125b056b7bab73684dd3f
|
4
|
+
data.tar.gz: 6fad0280817f00e0c0e3e8c6ef3761a5bd20d3e3a777a9f91182e556fad59aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e6aa6b5b10734d82c66f9f7f315c5759700412ddda2642e2424f71c8be71aca06d35aa77b69936514c8e3d0ddc2e5dd24d479e8c4359ff9d67e43222ebe0256
|
7
|
+
data.tar.gz: f762c62cadc6476aebfc9f0f2aee72bd254b32b93c1c069c22c67661482ac433b2598ff1f86f2f1cad943dcf28878bac4f3293025d7b45e26cb34aec3c6fbc81
|
data/lib/braintree/dispute.rb
CHANGED
@@ -561,6 +561,10 @@ module Braintree
|
|
561
561
|
UnitTaxAmountCannotBeNegative = "95826"
|
562
562
|
UnitTaxAmountFormatIsInvalid = "95824"
|
563
563
|
UnitTaxAmountIsTooLarge = "95825"
|
564
|
+
UPCCodeIsMissing = "95830"
|
565
|
+
UPCCodeIsTooLong = "95831"
|
566
|
+
UPCTypeIsMissing = "95832"
|
567
|
+
UPCTypeIsInvalid = "95833"
|
564
568
|
end
|
565
569
|
|
566
570
|
module Merchant
|
data/lib/braintree/http.rb
CHANGED
@@ -8,7 +8,6 @@ module Braintree
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def delete(path, query_params = {})
|
11
|
-
full_path = path + _build_query_string(query_params)
|
12
11
|
response = _http_do Net::HTTP::Delete, path
|
13
12
|
if response.code.to_i == 200 || response.code.to_i == 204
|
14
13
|
true
|
@@ -20,7 +19,6 @@ module Braintree
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def get(path, query_params = {})
|
23
|
-
full_path = path + _build_query_string(query_params)
|
24
22
|
response = _http_do Net::HTTP::Get, path
|
25
23
|
if response.code.to_i == 200 || response.code.to_i == 422
|
26
24
|
Xml.hash_from_xml(_body(response))
|
@@ -69,7 +67,7 @@ module Braintree
|
|
69
67
|
|
70
68
|
def _setup_connection(server = @config.server, port = @config.port)
|
71
69
|
if @config.proxy_address
|
72
|
-
|
70
|
+
Net::HTTP.new(
|
73
71
|
server,
|
74
72
|
port,
|
75
73
|
@config.proxy_address,
|
@@ -78,7 +76,7 @@ module Braintree
|
|
78
76
|
@config.proxy_pass,
|
79
77
|
)
|
80
78
|
else
|
81
|
-
|
79
|
+
Net::HTTP.new(server, port)
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class PackageDetails
|
4
|
+
include BaseModule
|
5
|
+
|
6
|
+
attr_reader :carrier
|
7
|
+
attr_reader :id
|
8
|
+
attr_reader :paypal_tracking_id
|
9
|
+
attr_reader :tracking_number
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -138,6 +138,7 @@ module Braintree
|
|
138
138
|
attr_reader :network_token_details
|
139
139
|
attr_reader :network_transaction_id
|
140
140
|
attr_reader :order_id
|
141
|
+
attr_reader :packages
|
141
142
|
attr_reader :partial_settlement_transaction_ids
|
142
143
|
attr_reader :payment_instrument_type
|
143
144
|
attr_reader :payment_receipt
|
@@ -284,6 +285,14 @@ module Braintree
|
|
284
285
|
return_object_or_raise(:transaction) { update_details(*args) }
|
285
286
|
end
|
286
287
|
|
288
|
+
def self.package_tracking(*args)
|
289
|
+
Configuration.gateway.transaction.package_tracking(*args)
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.package_tracking!(*args)
|
293
|
+
Configuration.gateway.transaction.package_tracking!(*args)
|
294
|
+
end
|
295
|
+
|
287
296
|
def self.submit_for_partial_settlement(*args)
|
288
297
|
Configuration.gateway.transaction.submit_for_partial_settlement(*args)
|
289
298
|
end
|
@@ -325,6 +334,7 @@ module Braintree
|
|
325
334
|
@sca_exemption_requested = attributes[:sca_exemption_requested]
|
326
335
|
@sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
|
327
336
|
@service_fee_amount = Util.to_big_decimal(service_fee_amount)
|
337
|
+
@packages = attributes[:shipments] ? attributes[:shipments].map { |pd| PackageDetails.new(pd) } : []
|
328
338
|
@shipping_details = AddressDetails.new(@shipping)
|
329
339
|
@status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
|
330
340
|
@subscription_details = SubscriptionDetails.new(@subscription)
|
@@ -112,6 +112,16 @@ module Braintree
|
|
112
112
|
return_object_or_raise(:transaction) { sale(*args) }
|
113
113
|
end
|
114
114
|
|
115
|
+
def package_tracking(transaction_id, package_tracking_request)
|
116
|
+
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
117
|
+
Util.verify_keys(TransactionGateway._package_tracking_request_signature, package_tracking_request)
|
118
|
+
_do_create "/transactions/#{transaction_id}/shipments", :shipment => package_tracking_request
|
119
|
+
end
|
120
|
+
|
121
|
+
def package_tracking!(*args)
|
122
|
+
return_object_or_raise(:transaction) { package_tracking(*args) }
|
123
|
+
end
|
124
|
+
|
115
125
|
def search(&block)
|
116
126
|
search = TransactionSearch.new
|
117
127
|
block.call(search) if block
|
@@ -187,6 +197,14 @@ module Braintree
|
|
187
197
|
return_object_or_raise(:transaction) { void(*args) }
|
188
198
|
end
|
189
199
|
|
200
|
+
def self._package_tracking_request_signature
|
201
|
+
[
|
202
|
+
:carrier,
|
203
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
204
|
+
:notify_payer, :tracking_number,
|
205
|
+
]
|
206
|
+
end
|
207
|
+
|
190
208
|
def self._clone_signature
|
191
209
|
[:amount, :channel, {:options => [:submit_for_settlement]}]
|
192
210
|
end
|
@@ -204,7 +222,7 @@ module Braintree
|
|
204
222
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
|
205
223
|
:transaction_source, :type, :venmo_sdk_payment_method_code, # Deprecated
|
206
224
|
:sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
|
207
|
-
{:line_items => [:
|
225
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
208
226
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
209
227
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
|
210
228
|
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
@@ -244,7 +262,7 @@ module Braintree
|
|
244
262
|
{:three_d_secure => [:required]},
|
245
263
|
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
|
246
264
|
{:venmo => [:profile_id]},
|
247
|
-
{:credit_card => [:account_type]},
|
265
|
+
{:credit_card => [:account_type, :process_debit_as_credit]},
|
248
266
|
]
|
249
267
|
},
|
250
268
|
{:external_vault => [
|
@@ -300,7 +318,7 @@ module Braintree
|
|
300
318
|
:discount_amount,
|
301
319
|
:shipping_amount,
|
302
320
|
:ships_from_postal_code,
|
303
|
-
:line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :
|
321
|
+
:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url],
|
304
322
|
]
|
305
323
|
end
|
306
324
|
|
@@ -1,18 +1,21 @@
|
|
1
1
|
module Braintree
|
2
2
|
class TransactionLineItem
|
3
3
|
include BaseModule
|
4
|
-
attr_reader :
|
5
|
-
attr_reader :name
|
4
|
+
attr_reader :commodity_code
|
6
5
|
attr_reader :description
|
7
|
-
attr_reader :kind
|
8
|
-
attr_reader :unit_amount
|
9
|
-
attr_reader :unit_tax_amount
|
10
|
-
attr_reader :unit_of_measure
|
11
6
|
attr_reader :discount_amount
|
7
|
+
attr_reader :image_url
|
8
|
+
attr_reader :kind
|
9
|
+
attr_reader :name
|
10
|
+
attr_reader :product_code
|
11
|
+
attr_reader :quantity
|
12
12
|
attr_reader :tax_amount
|
13
13
|
attr_reader :total_amount
|
14
|
-
attr_reader :
|
15
|
-
attr_reader :
|
14
|
+
attr_reader :unit_amount
|
15
|
+
attr_reader :unit_of_measure
|
16
|
+
attr_reader :unit_tax_amount
|
17
|
+
attr_reader :upc_code
|
18
|
+
attr_reader :upc_type
|
16
19
|
attr_reader :url
|
17
20
|
|
18
21
|
def initialize(gateway, attributes)
|
data/lib/braintree/util.rb
CHANGED
@@ -191,7 +191,7 @@ module Braintree
|
|
191
191
|
def self._get_invalid_keys(valid_keys, hash)
|
192
192
|
flattened_valid_keys = _flatten_valid_keys(valid_keys)
|
193
193
|
keys = _flatten_hash_keys(hash) - flattened_valid_keys
|
194
|
-
|
194
|
+
_remove_wildcard_keys(flattened_valid_keys, keys)
|
195
195
|
end
|
196
196
|
|
197
197
|
module IdEquality
|
data/lib/braintree/version.rb
CHANGED
@@ -15,13 +15,14 @@ module Braintree
|
|
15
15
|
Disbursement = "disbursement"
|
16
16
|
DisbursementException = "disbursement_exception"
|
17
17
|
|
18
|
-
DisputeOpened = "dispute_opened"
|
19
|
-
DisputeLost = "dispute_lost"
|
20
|
-
DisputeWon = "dispute_won"
|
21
18
|
DisputeAccepted = "dispute_accepted"
|
22
19
|
DisputeAutoAccepted = "dispute_auto_accepted"
|
23
20
|
DisputeDisputed = "dispute_disputed"
|
24
21
|
DisputeExpired = "dispute_expired"
|
22
|
+
DisputeLost = "dispute_lost"
|
23
|
+
DisputeOpened = "dispute_opened"
|
24
|
+
DisputeUnderReview = "dispute_under_review"
|
25
|
+
DisputeWon = "dispute_won"
|
25
26
|
|
26
27
|
GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"
|
27
28
|
|
@@ -34,12 +34,6 @@ module Braintree
|
|
34
34
|
case kind
|
35
35
|
when Braintree::WebhookNotification::Kind::Check
|
36
36
|
_check
|
37
|
-
when Braintree::WebhookNotification::Kind::DisputeOpened
|
38
|
-
_dispute_opened_sample_xml(id)
|
39
|
-
when Braintree::WebhookNotification::Kind::DisputeLost
|
40
|
-
_dispute_lost_sample_xml(id)
|
41
|
-
when Braintree::WebhookNotification::Kind::DisputeWon
|
42
|
-
_dispute_won_sample_xml(id)
|
43
37
|
when Braintree::WebhookNotification::Kind::DisputeAccepted
|
44
38
|
_dispute_accepted_sample_xml(id)
|
45
39
|
when Braintree::WebhookNotification::Kind::DisputeAutoAccepted
|
@@ -48,6 +42,14 @@ module Braintree
|
|
48
42
|
_dispute_disputed_sample_xml(id)
|
49
43
|
when Braintree::WebhookNotification::Kind::DisputeExpired
|
50
44
|
_dispute_expired_sample_xml(id)
|
45
|
+
when Braintree::WebhookNotification::Kind::DisputeLost
|
46
|
+
_dispute_lost_sample_xml(id)
|
47
|
+
when Braintree::WebhookNotification::Kind::DisputeOpened
|
48
|
+
_dispute_opened_sample_xml(id)
|
49
|
+
when Braintree::WebhookNotification::Kind::DisputeUnderReview
|
50
|
+
_dispute_under_review_sample_xml(id)
|
51
|
+
when Braintree::WebhookNotification::Kind::DisputeWon
|
52
|
+
_dispute_won_sample_xml(id)
|
51
53
|
when Braintree::WebhookNotification::Kind::PartnerMerchantConnected
|
52
54
|
_partner_merchant_connected_sample_xml(id)
|
53
55
|
when Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected
|
@@ -324,6 +326,14 @@ module Braintree
|
|
324
326
|
XML
|
325
327
|
end
|
326
328
|
|
329
|
+
def _dispute_under_review_sample_xml(id)
|
330
|
+
if id == "legacy_dispute_id"
|
331
|
+
_old_dispute_under_review_sample_xml(id)
|
332
|
+
else
|
333
|
+
_new_dispute_under_review_sample_xml(id)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
327
337
|
def _dispute_opened_sample_xml(id)
|
328
338
|
if id == "legacy_dispute_id"
|
329
339
|
_old_dispute_opened_sample_xml(id)
|
@@ -380,6 +390,26 @@ module Braintree
|
|
380
390
|
end
|
381
391
|
end
|
382
392
|
|
393
|
+
def _old_dispute_under_review_sample_xml(id)
|
394
|
+
<<-XML
|
395
|
+
<dispute>
|
396
|
+
<amount>100.00</amount>
|
397
|
+
<currency-iso-code>USD</currency-iso-code>
|
398
|
+
<received-date type="date">2014-03-01</received-date>
|
399
|
+
<reply-by-date type="date">2014-03-21</reply-by-date>
|
400
|
+
<kind>chargeback</kind>
|
401
|
+
<status>under_review</status>
|
402
|
+
<reason>fraud</reason>
|
403
|
+
<id>#{id}</id>
|
404
|
+
<transaction>
|
405
|
+
<id>#{id}</id>
|
406
|
+
<amount>100.00</amount>
|
407
|
+
</transaction>
|
408
|
+
<date-opened type=\"date\">2014-03-21</date-opened>
|
409
|
+
</dispute>
|
410
|
+
XML
|
411
|
+
end
|
412
|
+
|
383
413
|
def _old_dispute_opened_sample_xml(id)
|
384
414
|
<<-XML
|
385
415
|
<dispute>
|
@@ -521,6 +551,48 @@ module Braintree
|
|
521
551
|
XML
|
522
552
|
end
|
523
553
|
|
554
|
+
def _new_dispute_under_review_sample_xml(id)
|
555
|
+
<<-XML
|
556
|
+
<dispute>
|
557
|
+
<id>#{id}</id>
|
558
|
+
<amount>100.00</amount>
|
559
|
+
<amount-disputed>100.00</amount-disputed>
|
560
|
+
<amount-won>95.00</amount-won>
|
561
|
+
<case-number>CASE-12345</case-number>
|
562
|
+
<created-at type="datetime">2017-06-16T20:44:41Z</created-at>
|
563
|
+
<currency-iso-code>USD</currency-iso-code>
|
564
|
+
<forwarded-comments nil="true"/>
|
565
|
+
<kind>chargeback</kind>
|
566
|
+
<merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
|
567
|
+
<reason>fraud</reason>
|
568
|
+
<reason-code nil="true"/>
|
569
|
+
<reason-description nil="true"/>
|
570
|
+
<received-date type="date">2016-02-15</received-date>
|
571
|
+
<reference-number>REF-9876</reference-number>
|
572
|
+
<reply-by-date type="date">2016-02-22</reply-by-date>
|
573
|
+
<status>under_review</status>
|
574
|
+
<updated-at type="datetime">2017-06-16T20:44:41Z</updated-at>
|
575
|
+
<original-dispute-id>9qde5qgp</original-dispute-id>
|
576
|
+
<status-history type="array">
|
577
|
+
<status-history>
|
578
|
+
<status>under_review</status>
|
579
|
+
<timestamp type="datetime">2017-06-16T20:44:41Z</timestamp>
|
580
|
+
</status-history>
|
581
|
+
</status-history>
|
582
|
+
<evidence type="array"/>
|
583
|
+
<transaction>
|
584
|
+
<id>#{id}</id>
|
585
|
+
<amount>100.00</amount>
|
586
|
+
<created-at>2017-06-21T20:44:41Z</created-at>
|
587
|
+
<order-id nil="true"/>
|
588
|
+
<purchase-order-number nil="true"/>
|
589
|
+
<payment-instrument-subtype>Visa</payment-instrument-subtype>
|
590
|
+
</transaction>
|
591
|
+
<date-opened type=\"date\">2014-03-21</date-opened>
|
592
|
+
</dispute>
|
593
|
+
XML
|
594
|
+
end
|
595
|
+
|
524
596
|
def _new_dispute_opened_sample_xml(id)
|
525
597
|
<<-XML
|
526
598
|
<dispute>
|
data/lib/braintree/xml/parser.rb
CHANGED
@@ -32,7 +32,7 @@ module Braintree
|
|
32
32
|
case value.class.to_s
|
33
33
|
when "Hash"
|
34
34
|
if value["type"] == "array"
|
35
|
-
|
35
|
+
_child_key, entries = value.detect { |k,_v| k != "type" } # child_key is throwaway
|
36
36
|
if entries.nil? || ((c = value[CONTENT_ROOT]) && c.strip.empty?)
|
37
37
|
[]
|
38
38
|
else
|
@@ -47,7 +47,7 @@ module Braintree
|
|
47
47
|
end
|
48
48
|
elsif value.has_key?(CONTENT_ROOT)
|
49
49
|
content = value[CONTENT_ROOT]
|
50
|
-
if (
|
50
|
+
if (XML_PARSING[value["type"]])
|
51
51
|
XML_PARSING[value["type"]].call(content)
|
52
52
|
else
|
53
53
|
content
|
data/lib/braintree.rb
CHANGED
@@ -156,6 +156,7 @@ require "braintree/transaction/payment_receipt/card_present_data.rb"
|
|
156
156
|
require "braintree/transaction/payment_receipt/merchant_address.rb"
|
157
157
|
require "braintree/transaction/meta_checkout_card_details"
|
158
158
|
require "braintree/transaction/meta_checkout_token_details"
|
159
|
+
require "braintree/transaction/package_details"
|
159
160
|
require "braintree/transaction/paypal_details"
|
160
161
|
require "braintree/transaction/paypal_here_details"
|
161
162
|
require "braintree/transaction/samsung_pay_card_details"
|
@@ -203,7 +203,7 @@ describe Braintree::Address do
|
|
203
203
|
|
204
204
|
it "raises a NotFoundError if it cannot be found because of address id" do
|
205
205
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
206
|
-
|
206
|
+
Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
207
207
|
expect do
|
208
208
|
Braintree::Address.find(customer, "invalid")
|
209
209
|
end.to raise_error(
|
@@ -215,7 +215,7 @@ describe Braintree::Address do
|
|
215
215
|
describe "self.update" do
|
216
216
|
it "raises NotFoundError if the address can't be found" do
|
217
217
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
218
|
-
|
218
|
+
Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
219
219
|
expect do
|
220
220
|
Braintree::Address.update(customer.id, "bad-id", {})
|
221
221
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -293,7 +293,7 @@ describe Braintree::Address do
|
|
293
293
|
describe "self.update!" do
|
294
294
|
it "raises NotFoundError if the address can't be found" do
|
295
295
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
296
|
-
|
296
|
+
Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
297
297
|
expect do
|
298
298
|
Braintree::Address.update!(customer.id, "bad-id", {})
|
299
299
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -263,19 +263,19 @@ describe Braintree::AdvancedSearch do
|
|
263
263
|
context "multiple_value_or_text_field" do
|
264
264
|
describe "in" do
|
265
265
|
it "works for the in operator" do
|
266
|
-
|
266
|
+
Braintree::Subscription.create(
|
267
267
|
:payment_method_token => @credit_card.token,
|
268
268
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
269
269
|
:price => "17",
|
270
270
|
).subscription
|
271
271
|
|
272
|
-
|
272
|
+
Braintree::Subscription.create(
|
273
273
|
:payment_method_token => @credit_card.token,
|
274
274
|
:plan_id => SpecHelper::TrialPlan[:id],
|
275
275
|
:price => "17",
|
276
276
|
).subscription
|
277
277
|
|
278
|
-
|
278
|
+
Braintree::Subscription.create(
|
279
279
|
:payment_method_token => @credit_card.token,
|
280
280
|
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
281
281
|
:price => "17",
|
@@ -28,14 +28,12 @@ describe Braintree::ClientToken do
|
|
28
28
|
|
29
29
|
describe "version" do
|
30
30
|
it "allows a client token version to be specified" do
|
31
|
-
config = Braintree::Configuration.instantiate
|
32
31
|
client_token_string = Braintree::ClientToken.generate(:version => 1)
|
33
32
|
client_token = JSON.parse(client_token_string)
|
34
33
|
expect(client_token["version"]).to eq(1)
|
35
34
|
end
|
36
35
|
|
37
36
|
it "defaults to 2" do
|
38
|
-
config = Braintree::Configuration.instantiate
|
39
37
|
client_token_string = Braintree::ClientToken.generate
|
40
38
|
client_token = decode_client_token(client_token_string)
|
41
39
|
expect(client_token["version"]).to eq(2)
|
@@ -144,7 +144,7 @@ def generate_invalid_us_bank_account_nonce
|
|
144
144
|
nonce_characters = "bcdfghjkmnpqrstvwxyz23456789".chars.to_a
|
145
145
|
nonce = "tokenusbankacct_"
|
146
146
|
nonce += 4.times.map { sample(nonce_characters) }.join("_")
|
147
|
-
nonce
|
147
|
+
nonce + "_xxx"
|
148
148
|
end
|
149
149
|
|
150
150
|
def _cosmos_post(token, url, payload)
|
@@ -276,7 +276,7 @@ describe Braintree::CreditCard do
|
|
276
276
|
:customer_id => customer.id,
|
277
277
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
278
278
|
:three_d_secure_pass_thru => {
|
279
|
-
:eci_flag => "
|
279
|
+
:eci_flag => "05",
|
280
280
|
:cavv => "some_cavv",
|
281
281
|
:xid => "some_xid",
|
282
282
|
:authentication_response => "Y",
|
@@ -298,7 +298,7 @@ describe Braintree::CreditCard do
|
|
298
298
|
:customer_id => customer.id,
|
299
299
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
300
300
|
:three_d_secure_pass_thru => {
|
301
|
-
:eci_flag => "
|
301
|
+
:eci_flag => "05",
|
302
302
|
:cavv => "some_cavv",
|
303
303
|
:xid => "some_xid",
|
304
304
|
:three_d_secure_version => "1.0.2",
|
@@ -310,7 +310,6 @@ describe Braintree::CreditCard do
|
|
310
310
|
:options => {:verify_card => true},
|
311
311
|
)
|
312
312
|
expect(result.success?).to eq(true)
|
313
|
-
|
314
313
|
end
|
315
314
|
|
316
315
|
it "returns 3DS info on cc verification" do
|
@@ -323,16 +322,15 @@ describe Braintree::CreditCard do
|
|
323
322
|
expect(result.success?).to eq(true)
|
324
323
|
|
325
324
|
three_d_secure_info = result.credit_card.verification.three_d_secure_info
|
326
|
-
expect(three_d_secure_info.
|
325
|
+
expect(three_d_secure_info.status).to eq("authenticate_successful")
|
327
326
|
expect(three_d_secure_info).to be_liability_shifted
|
328
327
|
expect(three_d_secure_info).to be_liability_shift_possible
|
329
|
-
expect(three_d_secure_info.
|
330
|
-
expect(three_d_secure_info.cavv).to
|
331
|
-
expect(three_d_secure_info.xid).to
|
332
|
-
expect(three_d_secure_info.eci_flag).to
|
333
|
-
expect(three_d_secure_info.three_d_secure_version).to
|
334
|
-
expect(three_d_secure_info.
|
335
|
-
expect(three_d_secure_info.three_d_secure_authentication_id).not_to be_nil
|
328
|
+
expect(three_d_secure_info.enrolled).to be_a(String)
|
329
|
+
expect(three_d_secure_info.cavv).to be_a(String)
|
330
|
+
expect(three_d_secure_info.xid).to be_a(String)
|
331
|
+
expect(three_d_secure_info.eci_flag).to be_a(String)
|
332
|
+
expect(three_d_secure_info.three_d_secure_version).to be_a(String)
|
333
|
+
expect(three_d_secure_info.three_d_secure_authentication_id).to be_a(String)
|
336
334
|
end
|
337
335
|
|
338
336
|
it "adds credit card with billing address to customer" do
|
@@ -650,7 +648,6 @@ describe Braintree::CreditCard do
|
|
650
648
|
end
|
651
649
|
|
652
650
|
it "errors with invalid account_type" do
|
653
|
-
customer = Braintree::Customer.create!
|
654
651
|
result = Braintree::CreditCard.create(
|
655
652
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
656
653
|
:expiration_month => "11",
|
@@ -667,7 +664,6 @@ describe Braintree::CreditCard do
|
|
667
664
|
end
|
668
665
|
|
669
666
|
it "errors when account_type not supported by merchant" do
|
670
|
-
customer = Braintree::Customer.create!
|
671
667
|
result = Braintree::CreditCard.create(
|
672
668
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
673
669
|
:expiration_month => "11",
|
@@ -793,7 +789,7 @@ describe Braintree::CreditCard do
|
|
793
789
|
result = Braintree::CreditCard.update(credit_card.token,
|
794
790
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
795
791
|
:three_d_secure_pass_thru => {
|
796
|
-
:eci_flag => "
|
792
|
+
:eci_flag => "05",
|
797
793
|
:cavv => "some_cavv",
|
798
794
|
:xid => "some_xid",
|
799
795
|
:authentication_response => "Y",
|
@@ -821,7 +817,7 @@ describe Braintree::CreditCard do
|
|
821
817
|
result = Braintree::CreditCard.update(credit_card.token,
|
822
818
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
823
819
|
:three_d_secure_pass_thru => {
|
824
|
-
:eci_flag => "
|
820
|
+
:eci_flag => "05",
|
825
821
|
:cavv => "some_cavv",
|
826
822
|
:three_d_secure_version=> "2.1.0",
|
827
823
|
:xid => "some_xid",
|
@@ -283,7 +283,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
283
283
|
it "returns prepaid on a prepaid card" do
|
284
284
|
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
285
285
|
|
286
|
-
|
286
|
+
Braintree::Customer.create(
|
287
287
|
:credit_card => {
|
288
288
|
:cardholder_name => cardholder_name,
|
289
289
|
:expiration_date => "05/2012",
|
@@ -405,7 +405,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
405
405
|
:amount => "10.00",
|
406
406
|
},
|
407
407
|
:three_d_secure_pass_thru => {
|
408
|
-
:eci_flag => "
|
408
|
+
:eci_flag => "05",
|
409
409
|
:cavv => "some_cavv",
|
410
410
|
:xid => "some_xid",
|
411
411
|
:three_d_secure_version => "1.0.2",
|