braintree 4.15.0 → 4.18.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/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- 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 +9 -9
- data/lib/braintree/credit_card_gateway.rb +8 -8
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +5 -5
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +8 -7
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +3 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +2 -1
- data/lib/braintree/transaction/credit_card_details.rb +1 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +32 -16
- data/lib/braintree/transaction_gateway.rb +30 -13
- data/lib/braintree/transaction_line_item.rb +13 -10
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +1 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +2 -2
- data/lib/braintree/webhook_notification_gateway.rb +4 -4
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +1 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +3 -3
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +5 -1
- data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_spec.rb +4 -5
- data/spec/integration/braintree/credit_card_verification_spec.rb +46 -1
- data/spec/integration/braintree/customer_spec.rb +4 -4
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +20 -0
- data/spec/integration/braintree/payment_method_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +72 -0
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
- data/spec/integration/braintree/transaction_search_spec.rb +27 -0
- data/spec/integration/braintree/transaction_spec.rb +299 -89
- data/spec/unit/braintree/base_module_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +13 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +9 -0
- data/spec/unit/braintree/http_spec.rb +1 -1
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +32 -3
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +5 -0
- data/spec/unit/braintree/venmo_profile_data_spec.rb +11 -0
- metadata +13 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
module Braintree
|
2
|
-
class WebhookNotificationGateway
|
2
|
+
class WebhookNotificationGateway
|
3
3
|
def initialize(gateway)
|
4
4
|
@gateway = gateway
|
5
5
|
@config = gateway.config
|
@@ -27,7 +27,7 @@ module Braintree
|
|
27
27
|
signature_pairs = signature_string.split("&")
|
28
28
|
valid_pairs = signature_pairs.select { |pair| pair.include?("|") }.map { |pair| pair.split("|") }
|
29
29
|
|
30
|
-
valid_pairs.detect do |public_key,
|
30
|
+
valid_pairs.detect do |public_key, _signature|
|
31
31
|
public_key == @config.public_key
|
32
32
|
end
|
33
33
|
end
|
@@ -36,8 +36,8 @@ module Braintree
|
|
36
36
|
public_key, signature = _matching_signature_pair(signature_string)
|
37
37
|
raise InvalidSignature, "no matching public key" if public_key.nil?
|
38
38
|
|
39
|
-
signature_matches = [payload, payload + "\n"].any? do |
|
40
|
-
payload_signature = Braintree::Digest.hexdigest(@config.private_key,
|
39
|
+
signature_matches = [payload, payload + "\n"].any? do |p|
|
40
|
+
payload_signature = Braintree::Digest.hexdigest(@config.private_key, p)
|
41
41
|
Braintree::Digest.secure_compare(signature, payload_signature)
|
42
42
|
end
|
43
43
|
raise InvalidSignature, "signature does not match payload - one has been modified" unless signature_matches
|
data/lib/braintree/xml/libxml.rb
CHANGED
data/lib/braintree/xml/parser.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Portions of this code were copied and modified from Ruby on Rails, released
|
2
2
|
# under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
|
3
3
|
module Braintree
|
4
|
-
module Xml
|
4
|
+
module Xml
|
5
5
|
CONTENT_ROOT = "__content__"
|
6
6
|
|
7
|
-
module Parser
|
7
|
+
module Parser
|
8
8
|
XML_PARSING = {
|
9
9
|
"datetime" => Proc.new { |time| ::Time.parse(time).utc },
|
10
10
|
"integer" => Proc.new { |integer| integer.to_i },
|
@@ -32,7 +32,7 @@ module Braintree
|
|
32
32
|
case value.class.to_s
|
33
33
|
when "Hash"
|
34
34
|
if value["type"] == "array"
|
35
|
-
child_key, entries = value.detect { |k,
|
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
|
data/lib/braintree/xml/rexml.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Portions of this code were copied and modified from Ruby on Rails, released
|
2
2
|
# under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
|
3
3
|
module Braintree
|
4
|
-
module Xml
|
5
|
-
module Rexml
|
4
|
+
module Xml
|
5
|
+
module Rexml
|
6
6
|
|
7
7
|
CONTENT_KEY = "__content__".freeze
|
8
8
|
|
data/lib/braintree/xml.rb
CHANGED
data/lib/braintree.rb
CHANGED
@@ -3,7 +3,6 @@ require "bigdecimal"
|
|
3
3
|
require "cgi"
|
4
4
|
require "date"
|
5
5
|
require "digest/sha1"
|
6
|
-
require "enumerator"
|
7
6
|
require "forwardable"
|
8
7
|
require "logger"
|
9
8
|
require "net/http"
|
@@ -91,6 +90,8 @@ require "braintree/merchant_account/individual_details"
|
|
91
90
|
require "braintree/merchant_account/business_details"
|
92
91
|
require "braintree/merchant_account/funding_details"
|
93
92
|
require "braintree/merchant_account/address_details"
|
93
|
+
require "braintree/meta_checkout_card"
|
94
|
+
require "braintree/meta_checkout_token"
|
94
95
|
require "braintree/oauth_gateway"
|
95
96
|
require "braintree/oauth_credentials"
|
96
97
|
require "braintree/payment_instrument_type"
|
@@ -153,6 +154,9 @@ require "braintree/transaction/installment/adjustment"
|
|
153
154
|
require "braintree/transaction/payment_receipt"
|
154
155
|
require "braintree/transaction/payment_receipt/card_present_data.rb"
|
155
156
|
require "braintree/transaction/payment_receipt/merchant_address.rb"
|
157
|
+
require "braintree/transaction/meta_checkout_card_details"
|
158
|
+
require "braintree/transaction/meta_checkout_token_details"
|
159
|
+
require "braintree/transaction/package_details"
|
156
160
|
require "braintree/transaction/paypal_details"
|
157
161
|
require "braintree/transaction/paypal_here_details"
|
158
162
|
require "braintree/transaction/samsung_pay_card_details"
|
@@ -282,8 +282,8 @@ class ClientApiHttp
|
|
282
282
|
params = {:credit_card => params}
|
283
283
|
params.merge!(
|
284
284
|
:authorization_fingerprint => @options[:authorization_fingerprint],
|
285
|
-
:shared_customer_identifier =>
|
286
|
-
:shared_customer_identifier_type =>
|
285
|
+
:shared_customer_identifier => @options[:shared_customer_identifier],
|
286
|
+
:shared_customer_identifier_type => @options[:shared_customer_identifier_type],
|
287
287
|
)
|
288
288
|
|
289
289
|
post("/merchants/#{config.merchant_id}/client_api/v1/payment_methods/credit_cards", params)
|
@@ -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
|
@@ -793,7 +792,7 @@ describe Braintree::CreditCard do
|
|
793
792
|
result = Braintree::CreditCard.update(credit_card.token,
|
794
793
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
795
794
|
:three_d_secure_pass_thru => {
|
796
|
-
:eci_flag => "
|
795
|
+
:eci_flag => "05",
|
797
796
|
:cavv => "some_cavv",
|
798
797
|
:xid => "some_xid",
|
799
798
|
:authentication_response => "Y",
|
@@ -821,7 +820,7 @@ describe Braintree::CreditCard do
|
|
821
820
|
result = Braintree::CreditCard.update(credit_card.token,
|
822
821
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
823
822
|
:three_d_secure_pass_thru => {
|
824
|
-
:eci_flag => "
|
823
|
+
:eci_flag => "05",
|
825
824
|
:cavv => "some_cavv",
|
826
825
|
:three_d_secure_version=> "2.1.0",
|
827
826
|
:xid => "some_xid",
|
@@ -48,6 +48,51 @@ describe Braintree::CreditCardVerification, "search" do
|
|
48
48
|
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "creates a new verification from external vault param" do
|
52
|
+
verification_params = {
|
53
|
+
:credit_card => {
|
54
|
+
:expiration_date => "05/2029",
|
55
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
56
|
+
},
|
57
|
+
:external_vault => {
|
58
|
+
:status => "will_vault"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
63
|
+
|
64
|
+
expect(result).to be_success
|
65
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
66
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
67
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
68
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
69
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
70
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "creates a new verification from risk data param" do
|
74
|
+
verification_params = {
|
75
|
+
:credit_card => {
|
76
|
+
:expiration_date => "05/2029",
|
77
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
78
|
+
},
|
79
|
+
:risk_data => {
|
80
|
+
:customer_browser => "IE7",
|
81
|
+
:customer_ip => "192.168.0.1"
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
86
|
+
|
87
|
+
expect(result).to be_success
|
88
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
89
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
90
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
91
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
92
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
93
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
94
|
+
end
|
95
|
+
|
51
96
|
it "returns processor response code and text as well as the additional processor response if declined" do
|
52
97
|
verification_params = {
|
53
98
|
:credit_card => {
|
@@ -360,7 +405,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
360
405
|
:amount => "10.00",
|
361
406
|
},
|
362
407
|
:three_d_secure_pass_thru => {
|
363
|
-
:eci_flag => "
|
408
|
+
:eci_flag => "05",
|
364
409
|
:cavv => "some_cavv",
|
365
410
|
:xid => "some_xid",
|
366
411
|
:three_d_secure_version => "1.0.2",
|
@@ -1132,7 +1132,7 @@ describe Braintree::Customer do
|
|
1132
1132
|
:number => 4111111111111111,
|
1133
1133
|
:expiration_date => "05/2060",
|
1134
1134
|
:three_d_secure_pass_thru => {
|
1135
|
-
:eci_flag => "
|
1135
|
+
:eci_flag => "05",
|
1136
1136
|
:cavv => "some_cavv",
|
1137
1137
|
:xid => "some_xid",
|
1138
1138
|
:three_d_secure_version => "1.0.2",
|
@@ -1167,7 +1167,7 @@ describe Braintree::Customer do
|
|
1167
1167
|
:number => 4111111111111111,
|
1168
1168
|
:expiration_date => "05/2060",
|
1169
1169
|
:three_d_secure_pass_thru => {
|
1170
|
-
:eci_flag => "
|
1170
|
+
:eci_flag => "05",
|
1171
1171
|
:cavv => "some_cavv",
|
1172
1172
|
:xid => "some_xid",
|
1173
1173
|
:authentication_response => "Y",
|
@@ -1451,7 +1451,7 @@ describe Braintree::Customer do
|
|
1451
1451
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1452
1452
|
:credit_card => {
|
1453
1453
|
:three_d_secure_pass_thru => {
|
1454
|
-
:eci_flag => "
|
1454
|
+
:eci_flag => "05",
|
1455
1455
|
:cavv => "some_cavv",
|
1456
1456
|
:xid => "some_xid",
|
1457
1457
|
:three_d_secure_version => "xx",
|
@@ -1475,7 +1475,7 @@ describe Braintree::Customer do
|
|
1475
1475
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1476
1476
|
:credit_card => {
|
1477
1477
|
:three_d_secure_pass_thru => {
|
1478
|
-
:eci_flag => "
|
1478
|
+
:eci_flag => "05",
|
1479
1479
|
:cavv => "some_cavv",
|
1480
1480
|
:xid => "some_xid",
|
1481
1481
|
:three_d_secure_version => "2.2.1",
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction do
|
4
|
+
describe "self.package_tracking" do
|
5
|
+
it "returns validation error message from gateway api" do
|
6
|
+
# Create Transaction
|
7
|
+
result = Braintree::Transaction.sale(
|
8
|
+
:amount => "100",
|
9
|
+
:options => {
|
10
|
+
:submit_for_settlement => true
|
11
|
+
},
|
12
|
+
:paypal_account => {
|
13
|
+
:payer_id => "fake-payer-id",
|
14
|
+
:payment_id => "fake-payment-id",
|
15
|
+
},
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(result.success?).to eq(true)
|
19
|
+
|
20
|
+
# Carrier name is required
|
21
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {tracking_number: "tracking_number_1"})
|
22
|
+
expect(invalidResult.message).to eq("Carrier name is required.")
|
23
|
+
|
24
|
+
# Tracking number is required
|
25
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {carrier: "UPS"})
|
26
|
+
expect(invalidResult.message).to eq("Tracking number is required.")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "successfully calls gateway API and adds package tracking information" do
|
30
|
+
|
31
|
+
# Create Transaction
|
32
|
+
result = Braintree::Transaction.sale(
|
33
|
+
:amount => "100",
|
34
|
+
:options => {
|
35
|
+
:submit_for_settlement => true
|
36
|
+
},
|
37
|
+
:paypal_account => {
|
38
|
+
:payer_id => "fake-payer-id",
|
39
|
+
:payment_id => "fake-payment-id",
|
40
|
+
},
|
41
|
+
)
|
42
|
+
|
43
|
+
expect(result.success?).to eq(true)
|
44
|
+
|
45
|
+
# Create First Package with 2 products
|
46
|
+
firstPackageResult = Braintree::Transaction.package_tracking(
|
47
|
+
result.transaction.id,
|
48
|
+
{
|
49
|
+
carrier: "UPS",
|
50
|
+
notify_payer: true,
|
51
|
+
tracking_number: "tracking_number_1",
|
52
|
+
line_items: [
|
53
|
+
{
|
54
|
+
product_code: "ABC 01",
|
55
|
+
name: "Best Product Ever",
|
56
|
+
quantity: "1",
|
57
|
+
description: "Best Description Ever",
|
58
|
+
upc_code: "51234567890",
|
59
|
+
upc_type: "UPC-A",
|
60
|
+
image_url: "https://example.com/image.png",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
product_code: "ABC 02",
|
64
|
+
name: "Best Product Ever",
|
65
|
+
quantity: "1",
|
66
|
+
description: "Best Description Ever",
|
67
|
+
upc_code: "51234567891",
|
68
|
+
upc_type: "UPC-A",
|
69
|
+
image_url: "https://example.com/image.png",
|
70
|
+
},
|
71
|
+
],
|
72
|
+
},
|
73
|
+
)
|
74
|
+
|
75
|
+
# First package is shipped by the merchant
|
76
|
+
expect(firstPackageResult.success?).to eq(true)
|
77
|
+
expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
|
78
|
+
expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
|
79
|
+
expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
80
|
+
|
81
|
+
|
82
|
+
# Create second package with 1 product
|
83
|
+
secondPackageResult = Braintree::Transaction.package_tracking(
|
84
|
+
result.transaction.id,
|
85
|
+
{
|
86
|
+
carrier: "FEDEX",
|
87
|
+
notify_payer: true,
|
88
|
+
tracking_number: "tracking_number_2",
|
89
|
+
line_items: [
|
90
|
+
{
|
91
|
+
product_code: "ABC 03",
|
92
|
+
name: "Best Product Ever",
|
93
|
+
quantity: "1",
|
94
|
+
description: "Best Description Ever",
|
95
|
+
},
|
96
|
+
]
|
97
|
+
},
|
98
|
+
)
|
99
|
+
|
100
|
+
# Second package is shipped by the merchant
|
101
|
+
expect(secondPackageResult.success?).to eq(true)
|
102
|
+
expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
|
103
|
+
expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
|
104
|
+
expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
105
|
+
|
106
|
+
# Find transaction gives both packages
|
107
|
+
findTransaction = Braintree::Transaction.find(result.transaction.id)
|
108
|
+
expect(findTransaction.packages.length).to eq(2)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -91,6 +91,26 @@ describe Braintree::PaymentMethodNonce do
|
|
91
91
|
expect(nonce.details.payer_info).to be_nil
|
92
92
|
end
|
93
93
|
|
94
|
+
it "return meta_checkout_card_details nonce if exist" do
|
95
|
+
result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutCard)
|
96
|
+
nonce = result.payment_method_nonce
|
97
|
+
nonce.details.bin.should == "401288"
|
98
|
+
nonce.details.last_two.should == "81"
|
99
|
+
nonce.details.card_type.should == "Visa"
|
100
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
101
|
+
nonce.details.expiration_month.should == "12"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "return meta_checkout_token_details nonce if exist" do
|
105
|
+
result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutToken)
|
106
|
+
nonce = result.payment_method_nonce
|
107
|
+
nonce.details.bin.should == "401288"
|
108
|
+
nonce.details.last_two.should == "81"
|
109
|
+
nonce.details.card_type.should == "Visa"
|
110
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
111
|
+
nonce.details.expiration_month.should == "12"
|
112
|
+
end
|
113
|
+
|
94
114
|
it "return paypal details if details exist" do
|
95
115
|
result = Braintree::PaymentMethodNonce.find("fake-paypal-one-time-nonce")
|
96
116
|
nonce = result.payment_method_nonce
|
@@ -342,7 +342,7 @@ describe Braintree::PaymentMethod do
|
|
342
342
|
:customer_id => customer.id,
|
343
343
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
344
344
|
:three_d_secure_pass_thru => {
|
345
|
-
:eci_flag => "
|
345
|
+
:eci_flag => "05",
|
346
346
|
:cavv => "some_cavv",
|
347
347
|
:xid => "some_xid",
|
348
348
|
:three_d_secure_version => "xx",
|
@@ -365,7 +365,7 @@ describe Braintree::PaymentMethod do
|
|
365
365
|
:customer_id => customer.id,
|
366
366
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
367
367
|
:three_d_secure_pass_thru => {
|
368
|
-
:eci_flag => "
|
368
|
+
:eci_flag => "05",
|
369
369
|
:cavv => "some_cavv",
|
370
370
|
:xid => "some_xid",
|
371
371
|
:three_d_secure_version => "1.0.2",
|
@@ -78,6 +78,78 @@ describe Braintree::PaymentMethod do
|
|
78
78
|
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do
|
83
|
+
customer = Braintree::Customer.create.customer
|
84
|
+
result = Braintree::PaymentMethod.create(
|
85
|
+
:payment_method_nonce => Braintree::Test::Nonce::UsBankAccount,
|
86
|
+
:customer_id => customer.id,
|
87
|
+
:options => {
|
88
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
89
|
+
:verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification,
|
90
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
91
|
+
},
|
92
|
+
)
|
93
|
+
|
94
|
+
expect(result).to be_success
|
95
|
+
us_bank_account = result.payment_method
|
96
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
97
|
+
expect(us_bank_account.routing_number).to eq("123456789")
|
98
|
+
expect(us_bank_account.last_4).to eq("0000")
|
99
|
+
expect(us_bank_account.account_type).to eq("checking")
|
100
|
+
expect(us_bank_account.account_holder_name).to eq("Dan Schulman")
|
101
|
+
expect(us_bank_account.bank_name).to match(/Wells Fargo/)
|
102
|
+
expect(us_bank_account.default).to eq(true)
|
103
|
+
expect(us_bank_account.ach_mandate.text).to eq("example mandate text")
|
104
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
105
|
+
|
106
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
107
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
108
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
109
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
110
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
111
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("1000")
|
112
|
+
expect(us_bank_account.verified).to eq(true)
|
113
|
+
|
114
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns additional processor response for failed NetworkCheck" do
|
118
|
+
customer = Braintree::Customer.create.customer
|
119
|
+
invalid_nonce = generate_non_plaid_us_bank_account_nonce(account_number = "1000000005")
|
120
|
+
result = Braintree::PaymentMethod.create(
|
121
|
+
:payment_method_nonce => invalid_nonce,
|
122
|
+
:customer_id => customer.id,
|
123
|
+
:options => {
|
124
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
125
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
126
|
+
},
|
127
|
+
)
|
128
|
+
|
129
|
+
expect(result).to be_success
|
130
|
+
us_bank_account = result.payment_method
|
131
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
132
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
133
|
+
expect(us_bank_account.last_4).to eq("0005")
|
134
|
+
expect(us_bank_account.account_type).to eq("checking")
|
135
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
136
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
137
|
+
expect(us_bank_account.default).to eq(true)
|
138
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
139
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
140
|
+
|
141
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
142
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::ProcessorDeclined)
|
143
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
144
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
145
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
146
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("2061")
|
147
|
+
expect(us_bank_account.verifications.first.additional_processor_response).to eq("Invalid routing number")
|
148
|
+
|
149
|
+
expect(us_bank_account.verified).to eq(false)
|
150
|
+
|
151
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
152
|
+
end
|
81
153
|
end
|
82
154
|
|
83
155
|
it "fails with invalid nonce" do
|
@@ -18,6 +18,9 @@ describe Braintree::TransactionLineItem do
|
|
18
18
|
:kind => "debit",
|
19
19
|
:unit_amount => "45.1232",
|
20
20
|
:total_amount => "45.15",
|
21
|
+
:upc_code => "11223344556677889",
|
22
|
+
:upc_type => "UPC-A",
|
23
|
+
:image_url => "https://google.com/image.png",
|
21
24
|
},
|
22
25
|
],
|
23
26
|
)
|
@@ -32,6 +35,9 @@ describe Braintree::TransactionLineItem do
|
|
32
35
|
expect(line_item.kind).to eq("debit")
|
33
36
|
expect(line_item.unit_amount).to eq(BigDecimal("45.1232"))
|
34
37
|
expect(line_item.total_amount).to eq(BigDecimal("45.15"))
|
38
|
+
expect(line_item.upc_type).to eq("UPC-A")
|
39
|
+
expect(line_item.upc_code).to eq("11223344556677889")
|
40
|
+
expect(line_item.image_url).to eq("https://google.com/image.png")
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -1494,6 +1494,33 @@ describe Braintree::Transaction, "search" do
|
|
1494
1494
|
}.to raise_error(Braintree::UnexpectedError)
|
1495
1495
|
end
|
1496
1496
|
end
|
1497
|
+
|
1498
|
+
it "searches by payment instrument type meta checkout" do
|
1499
|
+
meta_checkout_card_transaction = Braintree::Transaction.sale!(
|
1500
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1501
|
+
:options => {
|
1502
|
+
:submit_for_settlement => true
|
1503
|
+
},
|
1504
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard,
|
1505
|
+
)
|
1506
|
+
|
1507
|
+
meta_checkout_token_transaction = Braintree::Transaction.sale!(
|
1508
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1509
|
+
:options => {
|
1510
|
+
:submit_for_settlement => true
|
1511
|
+
},
|
1512
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken,
|
1513
|
+
)
|
1514
|
+
|
1515
|
+
collection = Braintree::Transaction.search do |search|
|
1516
|
+
search.payment_instrument_type.in ["MetaCheckout"]
|
1517
|
+
end
|
1518
|
+
|
1519
|
+
collection.maximum_size.should == 2
|
1520
|
+
txn_ids = collection.map(&:id)
|
1521
|
+
expect(txn_ids).to include(meta_checkout_card_transaction.id)
|
1522
|
+
expect(txn_ids).to include(meta_checkout_token_transaction.id)
|
1523
|
+
end
|
1497
1524
|
end
|
1498
1525
|
|
1499
1526
|
context "pagination" do
|